The AllMovie script:
I original codeprocedure ParseCast(HTML : String);
var
curPos, EndPos : Integer;
Name, Role, URL : String;
begin
curPos := Pos('<div id="results-table">', HTML);
if curPos < 1 then
Exit;
//Actors
EndPos := curPos;
curPos := PosFrom('http://www.allmovie.com/artist/', HTML, curPos);
while (curPos > 0) AND (curPos < PosFrom('</table>', HTML, EndPos)) do begin
EndPos := PosFrom('">', HTML, curPos);
URL := Copy(HTML, curPos, EndPos - curPos);
curPos := EndPos + 2;
EndPos := PosFrom('</a>', HTML, curPos);
Name := Copy(HTML, curPos, EndPos - curPos);
curPos := PosFrom('<em>', HTML, EndPos);
if curPos > 0 then begin
curPos := curPos + 4;
EndPos := PosFrom('</em>', HTML, curPos);
Role := Trim(Copy(HTML, curPos, EndPos - curPos));
end else begin
Role := '';
curPos := EndPos;
end;
AddMoviePerson(Name, '', Role, URL, ctActors);
if curPos > 0 then
curPos := PosFrom('http://www.allmovie.com/artist/', HTML, curPos)
else
Exit;
end;
end;
I replaced it with this codeprocedure ParseCast(HTML : String);
var
curPos, EndPos : Integer;
TmpStr : String;
Name, Role, URL : String;
begin
curPos := Pos('<div id="results-table">', HTML);
if curPos < 1 then
Exit;
TmpStr := '';
EndPos := curPos;
curPos := PosFrom('http://www.allmovie.com/artist/', HTML, curPos);
while (curPos > 0) AND (curPos < PosFrom('</table>', HTML, EndPos)) do begin
EndPos := PosFrom('">', HTML, curPos);
URL := Copy(HTML, curPos, EndPos - curPos);
curPos := EndPos + 2;
EndPos := PosFrom('</a>', HTML, curPos);
Name := Copy(HTML, curPos, EndPos - curPos);
curPos := PosFrom('<em>', HTML, EndPos);
if curPos > 0 then begin
curPos := curPos + 4;
EndPos := PosFrom('</em>', HTML, curPos);
Role := Trim(Copy(HTML, curPos, EndPos - curPos));
end else begin
Role := '';
curPos := EndPos;
end;
if TmpStr <> '' then
TmpStr := TmpStr + #13;
if URL <> '' then
TmpStr := TmpStr + '<link url="' + URL + '">';
TmpStr := TmpStr + Name;
if Role <> '' then
TmpStr := TmpStr + ' - ' + Role;
if URL <> '' then
TmpStr := TmpStr + '</link>';
if curPos > 0 then
curPos := PosFrom('http://www.allmovie.com/artist/', HTML, curPos)
else
Exit;
end;
AddCustomFieldValueByName('Actors', TmpStr);
end;
Actors are now in the custom items (custom items: custom field Actors and Memo field) just as Production.
[attachment deleted by admin]