Code: Select all
// GETINFO SCRIPTING
// Imports big picture from DVDnet.ru
{
* For use with Ant Movie Catalog 3.4.2 *
* www.ant.be.tf/moviecatalog ··· www.buypin.com *
* It is based on a script written Kamik aka SlawDD *
}
program DVDnet_PICT;
const
BaseAddress = 'http://www.dvdnet.ru/';
var
MovieName: string;
MovieName2: 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 AddMoviesTitlesDVD(Page: TStringList; var LineNr: Integer);
var
Line: string;
MovieTitle, MovieAddress: string;
StartPos, EndPos: Integer;
begin
LineNr := FindLine('<b>ÔÈËÜÌÛ (æàíð è àêò¸ðû, èãðàþùèå ãëàâíûå ðîëè):</b><br>', Page, 0);
Line := Page.GetString(LineNr);
repeat
WHILE pos('<a href="index', Line)>0 DO
BEGIN
StartPos := pos('<a href="index', Line) + 9;
MovieAddress := copy(Line, StartPos, pos('">', Line) - StartPos);
StartPos := pos('">', Line) + 2;
MovieTitle := copy(Line, StartPos, pos('</i>', Line) - StartPos);
Delete(Line, 1, pos(' </a><br><', Line));
HTMLDecode(Movietitle);
HTMLRemoveTags(MovieTitle);
PickTreeAdd(MovieTitle, BaseAddress + MovieAddress);
end;
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
until (pos('<b>ÌÓËÜÒÔÈËÜÌÛ:</b><br>', Line)>0) or (pos('</table>', Line)>0);
end;
procedure AddAnimeTitlesDVD(Page: TStringList; var LineNr: Integer);
var
Line: string;
MovieTitle, MovieAddress: string;
StartPos, EndPos: Integer;
begin
LineNr := FindLine('<b>ÌÓËÜÒÔÈËÜÌÛ:</b><br>', Page, 0);
Line := Page.GetString(LineNr);
repeat
WHILE pos('<a href="index', Line)>0 DO
begin
StartPos := pos('<a href="index', Line) + 9;
MovieAddress := copy(Line, StartPos, pos('">', Line) - StartPos);
StartPos := pos('">', Line) + 2;
MovieTitle := copy(Line, StartPos, pos('</i>', Line) - StartPos);
Delete(Line, 1, pos(' </a><br><', Line));
HTMLDecode(Movietitle);
HTMLRemoveTags(MovieTitle);
PickTreeAdd(MovieTitle, BaseAddress + MovieAddress);
end;
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
until (pos('</table>', Line)>0);
end;
procedure AddPictureDVD(Page: TStringList);
var
Line, Value : string;
LineNr, BeginPos, EndPos: Integer;
begin
// Get Picture
LineNr := FindLine('window.open("pict', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('"pict', Line);
Delete(Line, 1, BeginPos);
EndPos := pos('"', Line);
Value := BaseAddress + copy(Line, 1, EndPos - 1);
GetPicture(Value, True); // False = do not store picture externally ; store it in the catalog file
end;
end;
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr, StartPos, EndPos, L: Integer;
Line: string;
MovieAddress, FindMovieName : string;
begin
PickTreeClear;
Page := TStringList.Create;
Page.Text := GetPage(Address);
if (pos('Ïî âàøåìó çàïðîñó â áàçå íàéäåíî:', Page.Text)>0) then
begin
PickTreeAdd('Íàéäåíî íà www.dvdnet.ru', '');
LineNr := FindLine('<b>ÔÈËÜÌÛ (æàíð è àêò¸ðû, èãðàþùèå ãëàâíûå ðîëè):</b><br>', Page, 0);
if LineNr >-1 then
begin
PickTreeAdd('Ôèëüìû', '');
AddMoviesTitlesDVD(Page, LineNr);
end;
LineNr := FindLine('<b>ÌÓËÜÒÔÈËÜÌÛ:</b><br>', Page, 0);
if LineNr > -1 then
begin
PickTreeAdd('Ìóëüòôèëüìû', '');
AddAnimeTitlesDVD(Page, LineNr);
end;
if PickTreeExec(Address) then
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
AddPictureDVD(Page);
end;
Page.Free;
end;
DisplayResults;
end;
begin
PickListClear;
if CheckVersion(3,4,0) then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then MovieName := GetField(fieldTranslatedTitle);
if Input('Import picture from DVDNet.ru', 'Enter the title of the movie:', MovieName) then
begin
MovieName2:=MovieName;
MovieName:=StringReplace(MovieName, '’', Chr(39));
MovieName:=AnsiLowerCase(MovieName);
MovieName:=AnsiUpFirstLetter(MovieName);
if pos('The ', MovieName)=1 then MovieName:=StringReplace(MovieName, 'The ', '');
AnalyzePage('http://www.dvdnet.ru/index.php?p=9&searching=y&checkform=y&search='+UrlEncode(MovieName));
end
else
ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
end;
end.