//This version of script is for use with PVD versions 0.9.9.16 and above!!!
(*
Additional types and functions that can be used in scripts:
---------------------------------------------
SCRIPT: iafd_movie script
AUTHOR: SusiMeier
DATE: 20/6/2010
VERSION: 0.0.1.3
CO-AUTHOR: Ivek23
SCRIPT MODIFICATION: Ivek23
MODIFICATION VERSION: 0.2.5.0
DATE: 29/12/2014
UPDATE: 7/2/2015
---------------------------------------------
//Types
TWIDEARRAY : array of String
//Field functions
procedure AddSearchResult(Title1, Title2, Year, URL, PreviewURL : String)
procedure AddFieldValue(AField: Integer; AValue : String)
procedure AddMoviePerson(Name, TransName, Role, URL : String; AType : Byte)
procedure AddPersonMovie(Title, OrigTitle, Role, Year, URL : String; AType : Byte)
procedure AddAward(Event, Award, Category, Recipient, Year: String; const Won : Boolean)
procedure AddConnection(Title, OrigTitle, Category, URL, Year: String)
procedure AddEpisode(Title, OrigTitle, Description, URL, Year, Season, Episode : String)
//String functions
function Pos(Substr : String; Str: String): Integer
function PosFrom(const SubStr, Str : String; FromIndex : Integer) : Integer
function LastPos(const SubStr, Str : String) : Integer
function PrevPos(const SubStr, Str : String; APos : Integer) : Integer
function RemoveTags(AText : String; doLineBreaks : Boolean) : String
function ExplodeString(AText : String; var Items : TWideArray; Delimiters : String) : Integer
function Copy(S: String; Index, Count: Integer): String
procedure Delete(var S: String; Index, Count: Integer)
procedure Insert(Source: String; var Dest: String; Index: Integer)
function Length(S: String): Integer
function Trim(S: String): String
function CompareText(S1, S2: String): Integer
function CompareStr(S1, S2: String): Integer
function UpperCase(S: String): String
function LowerCase(S: String): String
function StringReplace(S, OldPattern, NewPattern: String; ReplaceAll : Boolean; IgnoreCase : Boolean; WholeWord: Boolean): String
function StrToInt(const S: String): Integer
function IntToStr(const Value: Integer): String
function StrToFloat(const S: String): Extended
function FloatToStr(const Value: Extended): String
function HTMLValues(const HTML : String; ABegin, AEnd, ItemBegin, ItemEnd : String; ValDelim : String; var Pos : Integer) : String
function HTMLValues2(const HTML : String; ABegin, AEnd, ItemBegin, ItemEnd : String; ValDelim : String; var Pos : Integer) : String
function TextBetween(const HTML : String; ABegin, AEnd : String; doLineBreaks : Boolean; var Pos : Integer) : String
function HTMLToText(const HTML : String) : String
procedure ShowMessage(const Msg, Head : String)
*)
const
pauseBeforeLoad = 1000; // Pause before loading (in millisecond)
//Some useful constants
const
//Script types
stMovies = 0;
stPeople = 1;
stPoster = 2;
//Script modes
smSearch = 0;
smNormal = 1;
smPoster = 2;
//Parse results
prError = 0;
prFinished = 1;
prList = 2;
prListImage = 3;
prDownload = 4;
//Movie fields
mfURL = 0;
mfTitle = 1;
mfOrigTitle = 2;
mfAka = 3;
mfYear = 4;
mfGenre = 5;
mfCategory = 6;
mfCountry = 7;
mfStudio = 8;
mfMPAA = 9;
mfRating = 10;
mfTags = 11;
mfTagline = 12;
mfDescription = 13;
mfDuration = 14;
mfFeatures = 15;
//People fields
pfURL = 0;
pfName = 1;
pfTransName = 2;
pfAltNames = 3;
pfBirthday = 4;
pfBirthplace = 5;
pfGenre = 6;
pfBio = 7;
pfDeathDate = 8;
//Credits types
ctActors = 0;
ctDirectors = 1;
ctWriters = 2;
ctComposers = 3;
ctProducers = 4;
//Script data
//This version of script is for use with PVD versions 0.9.9.16 and above!!!
SCRIPT_VERSION = '0.3.1.0';
SCRIPT_NAME = 'IAFD.com_movie(NEW)';
SCRIPT_DESC = '[EN] Get movie full information from IAFD.com';
SCRIPT_LANG = $09; //English
SCRIPT_TYPE = stMovies;
BASE_URL = 'http://www.iafd.com';
RATING_NAME = 'ADE';
SEARCH_STR = 'www.iafd.com/results.asp?SearchType=Mozilla-search&SearchString=%s';
CODE_PAGE = 0; //Use 0 for Autodetect
//Global variables
var
Mode : Byte;
PosterURL : String;
//Functions
function GetScriptVersion : String;
begin
Result := SCRIPT_VERSION;
end;
function GetScriptName : String;
begin
Result := SCRIPT_NAME;
end;
function GetScriptDesc : String;
begin
Result := SCRIPT_DESC;
end;
function GetRatingName : String;
begin
Result := RATING_NAME;
end;
function GetScriptLang: Cardinal;
begin
Result := SCRIPT_LANG;
end;
function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;
function GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;
function GetDownloadURL : AnsiString;
begin
if PosterURL = '' then
Result := SEARCH_STR
else
Result := PosterURL;
end;
function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;
function GetCurrentMode : Byte;
begin
Result := Mode;
end;
function RemoveTagsEx(AText : String) : String;
var
B, E : Integer;
begin
Result := AText;
B := PosFrom('(', Result, 1);
E := PosFrom(')', Result, B);
while (B > 0) AND (B < E) do begin
Delete(Result, B, E - B + 1);
B := Pos('(', Result);
E := Pos(')', Result);
end;
end;
function RemoveTagsEx1(AText : String) : String;
var
B, E : Integer;
begin
Result := AText;
B := PosFrom('(', Result, 1);
E := PosFrom(']', Result, B);
while (B > 0) AND (B < E) do begin
Delete(Result, B, E - B + 1);
B := Pos('(', Result);
E := Pos(']', Result);
end;
end;
//procedure FindPoster(HTML : String);
//var
// curPos, EndPos : Integer;
//begin
// curPos := Pos('Box Cover ', HTML);
// curPos := PosFrom(' ', ' (', False, EndPos);
LogMessage('Title: ' + dbgstrg);
AddFieldValue(mfOrigTitle,dbgstrg);
AddFieldValue(mfTitle,dbgstrg);
// Year
dbgstrg:= Trim(TextBetween(HTML, '(', ')', False, EndPos));
LogMessage('YEAR:' + dbgstrg);
AddFieldValue(mfYear,dbgstrg);
// AKA - Titles...
LogMessage('getting all titles');
curPos := Pos('
Also Known As', HTML);
if curPos>0 then begin
curPos := PosFrom('Also Known As ', HTML,curPos)+22;
EndPos := PosFrom(' ',HTML,curPos);
dbgstrg:= Trim(Copy(HTML,curPos ,(EndPos-curPos)));
dbgstrg := StringReplace(dbgstrg,'',' ',true,true,true);
dbgstrg := StringReplace(dbgstrg,'','',true,true,true);
AddCustomFieldValueByName('IAFD AKA',dbgstrg);
dbgstrg0:= Trim(Copy(HTML,curPos ,(EndPos-curPos)));
dbgstrg0 := StringReplace(dbgstrg0,'','',true,true,true);
dbgstrg0 := StringReplace(dbgstrg0,' ',' ',true,true,true);
dbgstrg0 := StringReplace(dbgstrg0,'','',true,true,true);
dbgstrg0 := RemoveTagsEx(dbgstrg0);
dbgstrg0 := RemoveTagsEx1(dbgstrg0);
AddFieldValue(mfAka,dbgstrg0);
end;
// Director
// Same Code as for an actor
curPos := Pos('Director
0 then
begin
EndPos := curPos;
while (curPos > 0) AND (curPos < PosFrom('
Distributor
', HTML, UrlPosStart); // search for url start
URL := Trim(Copy(HTML, UrlPosStart + 7, (UrlPosEnd - UrlPosStart - 8) ));
URL := StringReplace(URL, '/person.rme/perfid=no_cred/gender=d/no-director-credited.htm', '', true, false, true);
URL := BASE_URL + '/' + URL;
LogMessage(URL);
// Get Name
actPosStart:=PosFrom('.htm">', HTML, curPos); // search for url start;
actPosEnd:=PosFrom('', HTML, actPosStart); // search for url end
if (actPosStart > 0) then
begin
Name := Trim(Copy(HTML, (actPosStart + Length('.htm">')), (actPosEnd - actPosStart - 6) ));
Name := StringReplace(Name, 'No Director Credited', '', true, false, true);
LogMessage(Name);
debug_pos1:=Pos('(',Name);
if debug_pos1 >0 then
Name := Copy(Name,0,debug_pos1-1);
LogMessage(Name);
AddMoviePerson(Trim(Name), '', '', LowerCase(URL), ctDirectors);
curPos := PosFrom('href="', HTML, actPosEnd);
end;
end;
end;
(*
// Distributor
// Same Code as for an actor
curPos := Pos('
Distributor
0 then
begin
// get url
Curpos := Posfrom('', HTML, Curpos);
//URL := BASE_URL + '/' + Trim(Copy(HTML, Curpos+9, Endpos- Curpos-9));
URL := BASE_URL + Trim(Copy(HTML, Curpos+10, Endpos- Curpos-10));
LogMessage(URL);
// Get Name
Curpos := Posfrom('">', HTML, Curpos)+2;
Endpos := PosFrom('
0) then
begin
Name := Trim(Copy(HTML, curPos, (endPos-curPos)));
Name := StringReplace(Name, 'Unknown', '', true, false, true);
//Name := StringReplace(Name, '/', '&', true, false, true);
Name := StringReplace(Name, '/', '-', true, false, true);
LogMessage(Name);
debug_pos1:=Pos('(',Name);
if debug_pos1 >0 then
Name := Copy(Name,0,debug_pos1-1);
LogMessage(Name);
// AddMoviePerson(Trim(Name), '', '', URL, ctDirectors); Where to store?
AddCustomFieldValueByName('IAFD Distributor',Name);
Distributor := ' ' + Name + '';
Distributor := StringReplace(Distributor, ' ', '', true, false, true);
if Distributor <> '' then Distributor := Distributor else Distributor := '';
//AddcustomFieldValueByName('IAFD Distributor1',Distributor);
//AddCustomFieldValueByName('IAFD Distributor1',' ' + Name + '');
//AddFieldValue(studio,Name)
curPos := PosFrom('VTO (VTO )
curPos := PosFrom(' 0 then
Studio1 := TextBetween(HTML, ' ', +'">', true, false, true);
Studio1 := StringReplace(Studio1, '', '', true, false, true);
Studio1 := StringReplace(Studio1, 'Distributor ', '', true, false, true);
Studio1 := StringReplace(Studio1, 'Unknown', '', true, false, true);
Studio1 := StringReplace(Studio1, ' ', '', true, false, true);
if Studio1 <> '' then Studio1 := Studio1 else Studio1 := '';
if Studio1 <> '' then AddCustomFieldValueByName('IAFD Studio1', Studio1);
// Studio
// VTO (VTO )
curPos := PosFrom('Studio (Distributor) ', HTML, EndPos);
if curPos > 0 then
//AddFieldValue(mfStudio, TextBetween(HTML, '">', ' ', False, curPos))
Studio0 := TextBetween(HTML, '">', '', False, curPos)
else
curPos := EndPos;
Studio0 := StringReplace(Studio0, 'Unknown', '', true, false, true);
Studio0 := StringReplace(Studio0, 'Unknown', '', true, false, true);
AddFieldValue(mfStudio, Studio0);
AddCustomFieldValueByName('IAFD Studio', Studio0);
//AddFieldValue(mfDescription,Studio0);
curPos := PosFrom(' Studio (Distributor) ', HTML, EndPos);
if curPos > 0 then
Studio2 := TextBetween(HTML, '', +'">', true, false, true);
Studio2 := StringReplace(Studio2, '', '', true, false, true);
Studio2 := StringReplace(Studio2, 'Distributor ', '', true, false, true);
Studio2 := StringReplace(Studio2, 'Unknown', '', true, false, true);
Studio2 := StringReplace(Studio2, ' ', '', true, false, true);
if Studio2 <> '' then Studio2 := Studio2 else Studio2 := '';
if Studio2 <> '' then AddCustomFieldValueByName('IAFD Studio1', Studio2);
*)
// Distributor Studio
curPos := Pos('Distributor
', HTML);
if curPos>0 then
begin
// get url
UrlPosStart := PosFrom('href=', HTML, curPos); // search for url start
UrlPosEnd := PosFrom('>', HTML, UrlPosStart); // search for url start
//URL := BASE_URL + '/' + Trim(Copy(HTML, UrlPosStart + 7, (UrlPosEnd - UrlPosStart - 8) ));
URL := BASE_URL + Trim(Copy(HTML, UrlPosStart + 7, (UrlPosEnd - UrlPosStart - 8) ));
LogMessage(URL);
// Get Name
actPosStart:=PosFrom('.htm">', HTML, curPos); // search for url start;
actPosEnd:=PosFrom(' ', HTML, actPosStart); // search for url end
if (actPosStart > 0) then
begin
Name := Trim(Copy(HTML, (actPosStart + Length('.htm">')), (actPosEnd - actPosStart - 6) ));
Name := StringReplace(Name, 'Unknown', '', true, false, true);
//Name := StringReplace(Name, '/', '&', true, false, true);
Name := StringReplace(Name, '/', '-', true, false, true);
LogMessage(Name);
debug_pos1:=Pos('(',Name);
if debug_pos1 >0 then
Name := Copy(Name,0,debug_pos1-1);
LogMessage(Name);
//AddCustomFieldValueByName('IAFD Distributor',Name);
//Distributor1 := ' ' + Name + '';
//Distributor1 := StringReplace(Distributor1, ' ', '', true, false, true);
if Distributor1 <> '' then Distributor1 := Distributor1 else Distributor1 := '';
AddFieldValue(8,Name);
//AddCustomFieldValueByName('IAFD Distributor1',Distributor1);
//AddCustomFieldValueByName('IAFD Distributor1',' ' + Name + '');
curPos := PosFrom('href="', HTML, Curpos);
end;
end;
// Cast
curPos := Pos('Performers ', HTML);
LogMessage('Cast readout');
if curPos > 0 then begin
EndPos := curPos;
while (curPos > 0) AND (curPos < PosFrom('', HTML, UrlPosStart); // search for url end
URL := BASE_URL + Trim(Copy(HTML, UrlPosStart + 6, (UrlPosEnd - UrlPosStart - 7) ));
LogMessage(URL);
// Get Name
actPosStart:=PosFrom('>
', HTML, EndPos); // search for url start;
actPosEnd:=PosFrom('', HTML, actPosStart); // search for url end
Name := Trim(Copy(HTML, (actPosStart + Length('>
')), (actPosEnd - actPosStart - 5) ));
Name := StringReplace(Name, 'No Director Credited', '', true, false, true);
LogMessage(Name);
debug_pos1:=Pos('(',Name);
if debug_pos1 >0 then
Name := Copy(Name,0,debug_pos1-1);
LogMessage(Name);
AddMoviePerson(Trim(Name), '', '', LowerCase(URL), ctActors);
curPos := PosFrom('href="', HTML, actPosEnd);
end;
end;
// Minutes
CurPos:= Pos('>Minutes
',HTML)+31;
if curPos > 0 then begin
//EndPos := CurPos;
//curPos := PosFrom('
', HTML, curPos)+4;
EndPos := PosFrom('', HTML, curPos);
Duration := IntToStr(StrToInt(Copy(HTML, curPos, EndPos - curPos)) * 60);
if Duration <> '' then
AddFieldValueXML('length',Duration);
end else
LogMessage('length not found');
Duration1 := Copy(HTML, curPos, EndPos - curPos);
Duration1 := StringReplace(Duration1, 'No Data', '', true, false, true);
if Duration1 <> '' then
Duration1 := 'Runtime : ' + Duration1 + ' Min.'
else
Duration1 := Duration1;
//fullinfo:= fullinfo + Duration1 + #13#10 + #13#10;
fullinfo:= fullinfo + Duration1 + #13#10;
(*
// Comments
curPos := Pos('Comments ', HTML);
if curPos > 0 then begin
LogMessage('Scene readout');
EndPos := curPos;
dbgstrg0 := '';
curPos := PosFrom('', HTML, curPos) + Length('', HTML, curPos);
dbgstrg0 := Copy(HTML, curPos, endPos - curPos);
dbgstrg0 := StringReplace(dbgstrg0, '', +'">', true, false, true);
dbgstrg0 := StringReplace(dbgstrg0, ' ', '', true, false, true);
dbgstrg0 := StringReplace(dbgstrg0, '.', '.', true, false, true);
dbgstrg0 := StringReplace(dbgstrg0, '', #13 + ''+#8226+' ', true, true, true);
dbgstrg0 := StringReplace(dbgstrg0, ' ', '', true, true, true);
dbgstrg0 := StringReplace(dbgstrg0, '__', '', true, true, true);
//dbgstrg0 := StringReplace(dbgstrg0, ' The credits on the DVD boxcover:', ' The credits on the DVD boxcover:', false, false, false);
//dbgstrg0 := StringReplace(dbgstrg0, 'Credits on cover: ', 'Credits on cover: ', true, true, true);
//dbgstrg0 := StringReplace(dbgstrg0, 'The credited cast: ', 'The credited cast: ', false, false, false);
//dbgstrg0 := StringReplace(dbgstrg0, ' -', ' -', true, true, true);
// dbgstrg0 := StringReplace(dbgstrg0, '. ', '. ', false, false, false);
//dbgstrg0 := StringReplace(dbgstrg0, ' ', ' ', false, false, false);
dbgstrg0 := StringReplace(dbgstrg0, ' ', ' ', false, false, false);
//dbgstrg0 := StringReplace(dbgstrg0, '(1)', ' (1)', true, true, true);
//dbgstrg0 := StringReplace(dbgstrg0, ' (', ' (', true, true, true);
dbgstrg0 := StringReplace(dbgstrg0, ' Scene', ' Scene', true, true, true);
dbgstrg0 := StringReplace(dbgstrg0, ' ', ' ', true, true, true);
dbgstrg0 := StringReplace(dbgstrg0, ' ', ' ', false, false, false);
dbgstrg0 := StringReplace(dbgstrg0, ' ', ' ', true, true, true);
dbgstrg0 := StringReplace(dbgstrg0, ' -', ' -', true, true, true);
dbgstrg0 := StringReplace(dbgstrg0, ' ', '', true, true, true);
dbgstrg0 := StringReplace(dbgstrg0, '', '', true, true, true);
If dbgstrg0 <> '' then
//dbgstrg0 := 'Comments :'+#13#10 + dbgstrg0
dbgstrg0 := 'Comments :' + dbgstrg0
else
dbgstrg0 := dbgstrg0;
//AddFieldValueXML('comment',dbgstrg0);
fullinfo:= fullinfo + dbgstrg0 + #13#10 + #13#10;
end;
//AddFieldValueXML('comment',fullinfo);
*)
// Scene Breakdowns
curPos := Pos('Scene Breakdowns ', HTML);
if curPos > 0 then begin
LogMessage('Scene readout');
EndPos := curPos;
curPos := PosFrom('Scene', HTML, EndPos+10);
dbgstrg := '';
J:=1;
//while (curPos > 0) AND (curPos < PosFrom('id=ratings', HTML, EndPos)) do begin
while (curPos > 0) AND (curPos < PosFrom('', HTML, EndPos+10)) do begin
// G
actPosStart:=PosFrom('Scene', HTML, curPos); // search for url start;
actPosEnd:=PosFrom('', HTML, actPosStart); // search for url end
Name := Trim (Copy(HTML, actPosStart,actPosEnd - actPosStart));
LogMessage(Name);
// NEW: Split string by comma and insert hyperlink-tags
// Scene 1. Julianne James, Tom Byron
// Final Strin: Scene ##. actor actor2
// remove static text from string (scene 1.) and split cleaned string by ','
tmpstrg := Copy(Name,10,100);
ActorNumber := ExplodeString(tmpstrg, ActorNames,',');
LogMessage(tmpstrg);
// Prepare first part of string...
//if dbgstrg <> '' then
//dbgstrg:= dbgstrg + ' '+#8226+' ' + 'Scene ' + IntToStr(j)+ '. '
//else
//dbgstrg:= dbgstrg;
dbgstrg:= dbgstrg + ' '+#8226+' ' + 'Scene ' + IntToStr(j)+ '. ';
// format splitted strings into links
For I := Low (ActorNames) To High (ActorNames) Do
begin
dbgstrg := dbgstrg+ ' ' + ActorNames[I] + ' ';
end;
dbgstrg:= dbgstrg + #13#10;
//dbgstrg:= dbgstrg + Name + #13#10;
j:=j+1;
curPos := PosFrom('Scene', HTML, actPosEnd);
end;
LogMessage(dbgstrg);
If dbgstrg <> '' then
dbgstrg := 'Scene Breakdowns :' +#13#10 + dbgstrg
else
dbgstrg := dbgstrg;
AddFieldValue(mfTagline,dbgstrg);
end;
(*
// Honors and Awards
dbgstrg1 := '';
LogMessage('HONOR & AWARDS4');
curPos := Pos('Honors and Awards ', HTML);
if curPos>0 then begin
//curPos := PosFrom('">', HTML,CurPos);
curPos := PosFrom('', HTML, EndPos);
if curPos > 0 then begin
curPos := curPos + Length('');
EndPos := PosFrom(' ', HTML, curPos);
dbgstrg3 := Trim(Copy(HTML, curPos, endPos - curPos));
//dbgstrg3 := Trim(Copy(HTML,curPos,(EndPos-curPos)));
logmessage('DBSTRG3 :'+dbgstrg3);
curPos := PosFrom('', HTML, curPos);
//if curPos > 0 then begin
curPos := curPos + Length('');
endPos := PosFrom(' ', HTML, curPos);
dbgstrg2 := Copy(HTML, curPos, endPos - curPos);
dbgstrg2 := StringReplace(dbgstrg2, '', #13+' '+#8226+' ', true, false, true);
logmessage('DBGTRG2 :'+dbgstrg2);
curPos := PosFrom(' ', HTML, curPos);
if curPos > 0 then begin
curPos := curPos + Length(' ', HTML, curPos);
dbgstrg4 := Copy(HTML, curPos, endPos - curPos);
dbgstrg4 := StringReplace(dbgstrg4, '', #13+' '+#8226+' ', true, false, true);
dbgstrg4 := StringReplace(dbgstrg4, ' Nominee: ', #13+' '+#8226+' Nominee: ', true, false, true);
dbgstrg4 := StringReplace(dbgstrg4, ' Nominee: ', #13+' '+#8226+' Nominee: ', true, false, true);
dbgstrg4 := StringReplace(dbgstrg4, ' ', #13+' '+#8226+' ', true, false, true);
dbgstrg4 := StringReplace(dbgstrg4, '', '', true, false, true);
dbgstrg4 := StringReplace(dbgstrg4, ' ', '', true, false, true);
dbgstrg4 := StringReplace(dbgstrg4, '', '', true, false, true);
dbgstrg4 := StringReplace(dbgstrg4, ' ', '', true, false, true);
if dbgstrg1 <> '' then
dbgstrg1 := dbgstrg1 + #13;
if dbgstrg3 <> '' then
dbgstrg1 := dbgstrg1 + ' '+#8226+' ' + dbgstrg3 + #13;
if dbgstrg2 <> '' then
dbgstrg1 := dbgstrg1 + ' '+#8226+' ' + dbgstrg2 + #13
else
dbgstrg1 := dbgstrg1 + ' '+#8226+' ' + dbgstrg4 + #13;
if dbgstrg1 <> '' then
dbgstrg1 := 'Honors and Awards :' + #13 + dbgstrg1 + #13;
LogMessage(dbgstrg1);
//end;
end;
end;
end;
fullinfo:= fullinfo + dbgstrg1 + #13#10;
AddFieldValueXML('comment',fullinfo);
*)
(*
// AMRI Reviews
curPos := Pos('AMRI Reviews ', HTML);
if curPos > 0 then begin
LogMessage('Scene readout');
EndPos := curPos;
curPos := PosFrom ('
Reviewed by:
',HTML,EndPos);
if curPos > 0 then begin
Curpos := Posfrom('
', HTML, Curpos);
LogMessage('endPos :' + IntToStr(endPos));
URL := BASE_URL + Trim(Copy(HTML, Curpos+33, Endpos- Curpos-33));
LogMessage('URL :' + URL);
// Get Name
Curpos := PosFrom('">', HTML, Endpos) + 2;
LogMessage('curPos :' + IntToStr(Endpos));
endPos := PosFrom(' ', HTML, curPos);
LogMessage('endPos :' + IntToStr(endPos));
Name := Trim(Copy(HTML, curPos, (endPos-curPos)));
Name := StringReplace(Name,' ',' ',true,true,true);
Name := StringReplace(Name,'','',true,true,true);
LogMessage('Name :' + Name);
// Fullinfo BioField:
If URL <> '' then
begin
dbgstrg5 := dbgstrg5 + '
' + Name + '' + ' ';
end;
LogMessage(dbgstrg5);
Curpos := Posfrom('
', HTML, Curpos);
LogMessage('endPos :' + IntToStr(endPos));
URL1 := Trim(Copy(HTML, Curpos+32, Endpos- Curpos-32));
LogMessage('URL1 :' + URL1);
// Get Name
Curpos := PosFrom('">', HTML, Endpos) + 2;
LogMessage('curPos :' + IntToStr(Endpos));
endPos := PosFrom(' ', HTML, curPos);
LogMessage('endPos :' + IntToStr(endPos));
Name1 := Trim(Copy(HTML, curPos, (endPos-curPos)));
Name1 := StringReplace(Name1,' ',' ',true,true,true);
Name1 := StringReplace(Name1,'','',true,true,true);
LogMessage('Name :' + Name1);
// Fullinfo BioField:
If URL1 <> '' then
begin
dbgstrg6 := dbgstrg6 + '
' + Name1 + '' + ' ';
end;
LogMessage(dbgstrg6);
Curpos := Posfrom('
',HTML,CurPos);
while (curPos > 0) AND (curPos < PosEnd) do begin
// Each movie entry starts with
URL:= textbetween(HTML,'href="','"',true,curpos);
URL:= BASE_URL + '/' + URL;
Title:= textbetween(HTML,'>',' ',true,curpos);
Year:= textbetween(HTML,'',' ',true,curpos);
Studio:= textbetween(HTML,'',' ',true,curpos);
AddSearchResult(Title, Studio, Year, URL, '');
curpos := posfrom('',HTML,curpos);
end;
end;
// ParsePage
// - Entrypoint for the script. Check if the search-term leads to zero, one or many results.
function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
Wait (pauseBeforeLoad);
LogMessage('Script version:' + SCRIPT_VERSION);
if Pos('Movie Titles - Top 50 Results ', HTML) > 0 then begin
ParseSearchResults(HTML);
Result := prList; //search results retrieved
end else
if Pos('Movie Titles - Top 50 Results ', HTML) < 0 then
Result := prError //error (movie not found)
else
if (Pos('movie details ', HTML) > 0) then begin
Mode := smNormal;
ParseMovie(URL, HTML);
Result := prFinished; //script has finished it's job
end else
Result := prError; //error (unknown page retrieved)
end;
begin
Mode := smSearch;
end.