www.dvdmepire.com script
Posted: 2004-03-28 18:53:28
is there a DVDEmpire script available?
Code: Select all
// GETINFO SCRIPTING
// www.dvdempire.com - by dmitry501
program From_dvdempire;
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;
// -------------------------------------------------------------------------------------------------------
function GetLines(Page: TStringList; LineNr: Integer): String;
var Value, Line: String;
StartPos : Integer;
begin
Value := '';
Line := Page.GetString(LineNr);
If Pos(' ',Line) > 0 Then Begin
Value := StringReplace(Line, '•', '');
HTMLDecode(Value);
HTMLRemoveTags(Value);
repeat
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
If Pos(' ',Line) > 0 Then Begin
Value := Value + ',' + StringReplace(Line, '•', '');
HTMLDecode(Value);
HTMLRemoveTags(Value);
end;
until Pos(' ',Line) < 1
end;
result := Trim(Value);
end;
// -------------------------------------------------------------------------------------------------------
procedure GetInfo(Page: TStringList; ItemID: String);
var Line, Value : String;
LineNR, StartPos : Integer;
begin
// URL
SetField(fieldURL,'http://www.dvdempire.com/Exec/v4_item.asp?item_id=' + ItemID);
//Rating
LineNr := FindLine('<b>Rating:</b>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr+3);
StartPos := Pos('(<b>',Line)+4;
Value := copy(Line, StartPos, pos('</b>', Line) - StartPos);
SetField(fieldRating,Value);
end;
// Year
LineNr := FindLine('<b>Production Year:</b>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
StartPos := Pos('</b>',Line)+5;
Value := Copy(Line, StartPos,4);
SetField(fieldYear, Value);
end;
// Director
LineNr := FindLine('<b>Directors:</b>', Page, 0);
if LineNr > -1 then
begin
Value := GetLines(Page, LineNr+1);
SetField(fieldDirector, Value);
end;
// Producer
LineNr := FindLine('<b>Producers:</b>', Page, 0);
if LineNr > -1 then
begin
Value := GetLines(Page, LineNr+1);
SetField(fieldProducer, Value);
end;
// Actors
LineNr := FindLine('<b>Actors:</b>', Page, 0);
if LineNr > -1 then
begin
Value := GetLines(Page, LineNr+1);
SetField(fieldActors, Value);
end;
// Description
LineNr := FindLine('<b> Synopsis</b>', Page, 0);
if LineNr > -1 then
begin
Value := Page.GetString(LineNr + 16)+Page.GetString(LineNr + 17)+Page.GetString(LineNr + 18);
Value:=StringReplace(Value, '>i<', '> <');
HTMLDecode(Value);
HTMLRemoveTags(Value);
SetField(fieldDescription,Value);
end;
// Picture
Line := 'http://images.dvdempire.com/gen/movies/' + ItemID + 'h.jpg';
GetPicture(Line, False);
end;
// -------------------------------------------------------------------------------------------------------
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr, StartPos, EndPos, L: Integer;
Line: string;
ItemID, MovieAddress, MovieTitle : string;
begin
PickTreeClear;
Page := TStringList.Create;
Page.Text := GetPage(Address);
LineNr := FindLine('<title>DVD Empire - Item -', Page, 0);
if LineNr >-1 then begin
LineNr := FindLine('item_id', Page, 0);
Line := Trim(Page.GetString(LineNr));
StartPos := pos('item_id=', Line) + 8;
ItemID := copy(Line, StartPos, pos('&tab=', Line) - StartPos);
GetInfo(Page,ItemID);
end else begin
LineNr := FindLine('Matches Found<br>', Page, 0);
if LineNr >-1 then begin
Line := Page.GetString(LineNr);
StartPos := pos('<b>', Line) + 3;
L := StrToInt('0'+ Copy(Line, StartPos, pos('</b>', Line) - StartPos),1);
PickTreeAdd(IntToStr(L)+' Matches found', '');
If L>0 Then begin
// Find Films
LineNr := FindLine('searchID=', Page, LineNr);
LineNr := LineNr + 1;
repeat
LineNr := FindLine('searchID=', Page, LineNr);
if LineNr >-1 then begin
Line := Trim(Page.GetString(LineNr));
LineNr := LineNr + 1;
If pos('<img src="', Line) <1 Then Begin
StartPos := pos('item_id=', Line) + 8;
ItemID := copy(Line, StartPos, pos('">', Line) - StartPos);
MovieAddress := 'http://www.dvdempire.com/Exec/v4_item.asp?item_id=' + ItemID;
StartPos := pos('">', Line) + 2;
MovieTitle := copy(Line, StartPos, 500);
HTMLDecode(Movietitle);
HTMLRemoveTags(MovieTitle);
PickTreeAdd(MovieTitle, MovieAddress);
end;
end;
until (LineNr <1 );
end;
end;
Page.Free;
if PickTreeExec(Address) then
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
ItemID :=copy(Address, 51, 8);
GetInfo(Page,ItemID);
end;
end;
DisplayResults;
end;
// -------------------------------------------------------------------------------------------------------
// Begin program
begin
PickListClear;
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then MovieName := GetField(fieldTranslatedTitle);
if Input('Import from www.dvdempire.com', '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.dvdempire.com/Exec/v5_search_item.asp?string='+UrlEncode(MovieName));
end
end.
3RAb wrote:script works, but only pulls movie poster. there are other info on its website too.
the movie i used to test was Silent Falls (1994)