Code: Select all
// GETINFO SCRIPTING
// Imports large picture from sharereactor.com
// Dmitry501
program Sharereactor_com;
const
BaseAddress = 'http://www.sharereactor.com/';
var
MovieName: string;
function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
var
i: Integer;
begin
result := -1;
if StartAt < 0 then
StartAt := 0;
for i := StartAt to List.Count-1 do
if Pos(Pattern, List.GetString(i)) <> 0 then
begin
result := i;
Break;
end;
end;
procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
var
Line: string;
MovieTitle, MovieAddress: string;
StartPos,EndPos,AddPos: Integer;
begin
LineNr := LineNr + 9;
Line := Page.GetString(LineNr);
StartPos := pos('<a', Line);
while StartPos > 0 do
begin
Line := Page.GetString(LineNr);
StartPos := pos('<a', Line);
if StartPos > 0 then
begin
StartPos:=StartPos+8;
EndPos := Length(Line);
Line:=copy(Line,StartPos,EndPos - StartPos);
MovieAddress := copy(Line, 2, pos('">', Line) -2 );
StartPos := pos('">', Line) + 2;
MovieTitle := copy(Line, StartPos, pos('</a>', Line) - StartPos);
HTMLDecode(Movietitle);
PickTreeAdd(MovieTitle, BaseAddress + MovieAddress);
end;
LineNr := LineNr + 4;
end;
end;
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr : Integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
PickTreeClear;
LineNr := 0;
LineNr := FindLine('Total Matches:', Page, LineNr);
if LineNr > -1 then
begin
PickTreeAdd('Total Matches:','');
AddMoviesTitles(Page, LineNr);
end;
if PickTreeExec(Address) then
begin
Page.Free;
AnalyzeMoviePage(Address)
end
end;
procedure AnalyzeMoviePage(Address: String);
var
Page: TStringList;
LineNr : Integer;
Line, Value : String;
BeginPos, EndPos : Integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
// Picture
LineNr := FindLine('Click here for a large version', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="', Line);
EndPos := pos('" target="_blank">', Line);
Value := copy(Line, BeginPos+9, EndPos - 9 - BeginPos);
GetPicture(Value, False);
end;
DisplayResults;
end;
begin
if CheckVersion(3,4,0) then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
if Input('Import picture from sharereactor.com', 'Enter the title of the movie:', MovieName) then
begin
AnalyzePage('http://www.sharereactor.com/search.php?search='+UrlEncode(MovieName)+'&category=0&submit=Search');
end;
end else
ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
end.