For Cast & Crew
Copy the below procedure ParseReview
//Parse Cast
//Modified 09/24/2010 to save entire Cast tab to custom memo field, as well as individual actors.
procedure ParseCast(HTML : String);
var
curPos, EndPos : Integer;
TmpStr, TmpStr1 : String;
Name, Role, URL : String;
begin
curPos := Pos('<div class="description-box">', HTML);
if curPos < 1 then
Exit;
TmpStr := '';
EndPos := curPos;
curPos := PosFrom('http://www.allrovi.com/name/', 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('>', HTML, EndPos);
if curPos > 0 then begin
curPos := curPos + 2;
EndPos := PosFrom('</td>', HTML, curPos);
Role := Trim(Copy(HTML, curPos +4, EndPos - curPos -4));
end else begin
Role := '';
curPos := EndPos;
end;
AddMoviePerson(Name, '', '', URL, ctActors);
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.allrovi.com/name/', HTML, curPos)
else
Exit;
end;
AddCustomFieldValueByName('Cast', TmpStr); // If you do not exist then the change to:
AddCustomFieldValueByName('Actors', TmpStr);
curPos := Pos('<div class="profession-box">', HTML);
if curPos < 1 then
Exit;
TmpStr := '';
EndPos := curPos;
curPos := PosFrom('http://www.allrovi.com/name/', HTML, curPos);
while (curPos > 0) AND (curPos < PosFrom('</dl>', HTML, EndPos)) do begin
EndPos := PosFrom('">', HTML, curPos);
URL := 'http://www.allrovi.com/name/' + Copy(HTML, curPos, EndPos - curPos);
curPos := EndPos + 2;
EndPos := PosFrom('</a>', HTML, curPos);
Name := Copy(HTML, curPos, EndPos - curPos);
curPos := PosFrom('>', HTML, EndPos);
if curPos > 0 then begin
curPos := curPos + 2;
EndPos := PosFrom('</dd>', HTML, curPos);
Role := Trim(Copy(HTML, curPos +4, EndPos - curPos -4));
end else begin
Role := '';
curPos := EndPos;
end;
AddMoviePerson(Name, '', Role, URL, ctProducers);
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.allrovi.com/name/', HTML, curPos)
else
Exit;
end;
AddCustomFieldValueByName('Production', TmpStr);
end;
Notice:
AddMoviePerson(Name, '', Role, URL, ctProducers);
This is only a test there to see how information is transferred
[s]GET_CAST = True;[/s]
//Get Cast URL
[s]if GET_CAST then begin[/s]
EndPos := Pos('"><span>cast & crew</span></a>', HTML);
if EndPos > 0 then begin
curPos := PrevPos('href="/movies', HTML, EndPos);
ExtraLinks[smCast] := BASE_URL + Copy(HTML, curPos + 6, EndPos - curPos - 6);
end;
[s]end; [/s]
Notice:
Strikethrough may be necessary
ParseReview(HTML)
else
if Pos('- Cast and Crew - AllRovi</title>', HTML) > 0 then
ParseCast(HTML):
This is now testing that might find a solution to the Role there because I leave this <td> and this <dd>, but I can not find solution how to remove this.
Notice:
If, however, it might be something, here are the necessary code:
procedure ParseCredits(HTML : String);
var
curPos, EndPos : Integer;
TmpStr, TmpStr1 : String;
Name, Role, URL : String;
begin
curPos := Pos('<div class="profession-box">', HTML);
if curPos < 1 then
Exit;
TmpStr := '';
EndPos := curPos;
curPos := PosFrom('http://www.allrovi.com/name/', HTML, curPos);
while (curPos > 0) AND (curPos < PosFrom('</dl>', HTML, EndPos)) do begin
EndPos := PosFrom('">', HTML, curPos);
URL := 'http://www.allrovi.com/name/' + Copy(HTML, curPos, EndPos - curPos);
curPos := EndPos + 2;
EndPos := PosFrom('</a>', HTML, curPos);
Name := Copy(HTML, curPos, EndPos - curPos);
curPos := PosFrom('>', HTML, EndPos);
if curPos > 0 then begin
curPos := curPos + 2;
EndPos := PosFrom('</dd>', HTML, curPos);
Role := Trim(Copy(HTML, curPos, EndPos - curPos));
end else begin
Role := '';
curPos := EndPos;
end;
AddMoviePerson(Name, '', Role, URL, ctProducers);
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.allrovi.com/name/', HTML, curPos)
else
Exit;
end;
AddCustomFieldValueByName('Production', TmpStr);
end;
//Get Review URL
if GET_REVIEW then begin
EndPos := Pos('"><span>review</span>', HTML);
if EndPos > 0 then begin
curPos := PrevPos('href="/movies', HTML, EndPos);
ExtraLinks[smReview] := BASE_URL + Copy(HTML, curPos + 6, EndPos - curPos - 6);
end;
end;
//Get Cast URL
if GET_CAST then begin
EndPos := Pos('"><span>cast & crew</span></a>', HTML);
if EndPos > 0 then begin
curPos := PrevPos('href="/movies', HTML, EndPos);
ExtraLinks[smCast] := BASE_URL + Copy(HTML, curPos + 6, EndPos - curPos - 6);
end;
end;
ParseReview(HTML)
else
if Pos('- Cast and Crew - AllRovi</title>', HTML) > 0 then
ParseCast(HTML)
else
if Pos('- Cast and Crew - AllRovi</title>', HTML) > 0 then
ParseCredits(HTML);