(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=Antoine Potten, Tim Roelandt Title=Mediadis Description=English version of Mediadis.com (Old DVDZone2) Site=http://www.mediadis.com Language=EN Version=1.01 Requires=3.5.0 Comments=Modded version of Antoine Potten's script for DVDZone2 that stopped working. License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. | GetInfo=1 [Options] ***************************************************) program DVDZone2_FR; 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 AnalyzePage(Address: string); var Line, MovieItem, MovieTitle, MovieAddress: string; TitlePos, BeginPos, EndPos: Integer; List: TStringList; begin Line := GetPage(Address); PickTreeClear; if Pos(' : 0 item(s) found
', Line) = 0 then begin PickTreeAdd('Search results from Mediadis', ''); BeginPos := Pos('', Line); EndPos := Pos('S BE PARTNERS -->', Line); Line := Copy(Line, BeginPos, EndPos - BeginPos); List := TStringList.Create; repeat TitlePos := Pos('', Line); if TitlePos > 0 then begin Delete(Line, 1, TitlePos); MovieItem := Copy(Line, 1, Pos(' Eur
', Line)); BeginPos := Pos('', MovieItem) + 13; EndPos := Pos('', MovieItem); MovieTitle := Copy(MovieItem, BeginPos, EndPos - BeginPos); List.Text := MovieItem; MovieItem := Trim(List.GetString(3)); if MovieItem <> '' then MovieTitle := MovieTitle + ' [' + MovieItem + ']'; MovieItem := Trim(List.GetString(9)); if MovieItem <> '' then MovieTitle := MovieTitle + ' (' + MovieItem + ')'; PickTreeAdd(MovieTitle, MovieAddress); Delete(Line, 1, 25); end; until TitlePos = 0; List.Free; end; if PickTreeExec(Address) then AnalyzeMoviePage(Address); end; procedure AnalyzeMoviePage(Address: string); var Line, Value, FullValue: string; LineNr: Integer; BeginPos, EndPos: Integer; Page: TStringList; begin Line := GetPage(Address); BeginPos := Pos('', Line); EndPos := Pos('', Line); Line := Copy(Line, BeginPos, EndPos - BeginPos); // title BeginPos := Pos('', Line); Delete(Line, 1, BeginPos); BeginPos := Pos('>', Line) + 1; EndPos := Pos(' 0 then begin Delete(Line, 1, BeginPos - 1); EndPos := Pos('"', Line); Value := Copy(Line, 1, EndPos - 1); GetPicture(Value); end; // description BeginPos := Pos('

', Line); if BeginPos > 0 then begin Delete(Line, 1, BeginPos + 2); EndPos := Pos(#13, Line); Value := StringReplace(Copy(Line, 1, EndPos - 1), '

', #13#10#13#10); HTMLRemoveTags(Value); HTMLDecode(Value); SetField(FieldDescription, Value); end; // rating BeginPos := Pos('Global rating', Line); if BeginPos > 0 then begin Delete(Line, 1, BeginPos); BeginPos := Pos('', Line); if BeginPos > 0 then begin BeginPos := BeginPos + 8; EndPos := Pos('/', Line); Value := Copy(Line, BeginPos, EndPos - BeginPos); SetField(fieldRating, Value); end; end; Page := TStringList.Create; BeginPos := Pos('', Line); Delete(Line, 1, BeginPos); EndPos := Pos('', Line); Page.Text := Copy(Line, 1, EndPos); // director //SetField(fieldDirector, GetInfo('Director(s)', Page)); Value := ''; BeginPos := Pos('Director(s)', Line); Delete(Line, 1, BeginPos); if Pos(' : 
', Line) <> 19 then begin repeat if Pos('
', Line) <> 1 then begin BeginPos := Pos('">', Line) + 2; EndPos := Pos('', Line); if Value <> '' then begin Value := Value + ', ' + Copy(Line, BeginPos, EndPos - BeginPos); end; if Value = '' then begin Value := Copy(Line, BeginPos, EndPos - BeginPos); end; HTMLDecode(Value); Delete(Line, 1, EndPos + 3); end; until Pos('
', Line) = 1; end; SetField(fieldDirector, Value); // actors //SetField(fieldActors, StringReplace(GetInfo('Actors', Page), ' - ', ', ')); Value := ''; BeginPos := Pos('Actors', Line); Delete(Line, 1, BeginPos); begin repeat if Pos('
', Line) <> 1 then begin BeginPos := Pos('">', Line) + 2; EndPos := Pos('', Line); if Value <> '' then begin Value := Value + ', ' + Copy(Line, BeginPos, EndPos - BeginPos); end; if Value = '' then begin Value := Copy(Line, BeginPos, EndPos - BeginPos); end; HTMLDecode(Value); Delete(Line, 1, EndPos + 3); end; until Pos('
', Line) = 1; end; SetField(fieldActors, Value); // country //SetField(fieldCountry, GetInfo('Country', Page)); BeginPos := Pos('Country', Line); Delete(Line, 1, BeginPos); BeginPos := Pos(': ', Line) + 7; EndPos := Pos('
', Line); Value := Copy(Line, BeginPos, EndPos - BeginPos); HTMLDecode(Value); SetField(fieldCountry, Value); // year //SetField(fieldYear, GetInfo('Year', Page)); BeginPos := Pos('Year', Line); Delete(Line, 1, BeginPos); BeginPos := Pos(': ', Line) + 7; EndPos := Pos('
', Line); Value := Copy(Line, BeginPos, EndPos - BeginPos); HTMLDecode(Value); SetField(fieldYear, Value); // studio (producer) //SetField(fieldProducer, GetInfo('Studio', Page)); BeginPos := Pos('Studio', Line); Delete(Line, 1, BeginPos); BeginPos := Pos(': ', Line) + 7; EndPos := Pos('
', Line); Value := Copy(Line, BeginPos, EndPos - BeginPos); HTMLDecode(Value); SetField(fieldProducer, Value); // category //SetField(fieldCategory, GetInfo('Genres', Page)); BeginPos := Pos('Genres', Line); Delete(Line, 1, BeginPos); BeginPos := Pos(': ', Line) + 7; EndPos := Pos('
', Line); Value := Copy(Line, BeginPos, EndPos - BeginPos); HTMLDecode(Value); SetField(fieldCategory, Value); //Release Date BeginPos := Pos('Release date', Line); Delete(Line, 1, BeginPos); BeginPos := Pos('
', Line) - 4; EndPos := Pos('
', Line); Value := Copy(Line, BeginPos, EndPos - BeginPos); HTMLDecode(Value); SetField(fieldYear, Value); // length BeginPos := Pos('Duration', Line); Delete(Line, 1, BeginPos); BeginPos := Pos(': ', Line) + 7; EndPos := Pos(' min', Line); Value := Copy(Line, BeginPos, EndPos - BeginPos); HTMLDecode(Value); SetField(fieldLength, Value); // special features (comments) BeginPos := Pos('Special features', Line); Delete(Line, 1, BeginPos); EndPos := Pos('', Line); Delete(Line, EndPos, Length(Line)); FullValue := ''; repeat BeginPos := Pos('', Line); Delete(Line, 1, BeginPos); BeginPos := Pos('', Line); if BeginPos > 0 then begin BeginPos := Pos('', Line); if BeginPos > 0 then begin Value := Copy(Line, BeginPos + 8, Length(Line)); EndPos := Pos(#10, Value); Value := StringReplace(Copy(Value, 1, EndPos - 1), '
', ' '); HTMLRemoveTags(Value); HTMLDecode(Value); FullValue := FullValue + '- ' + Value + #13#10; end; end; until (Pos('', Line) = 0) or (Pos('', Line) = 0); if FullValue <> '' then SetField(fieldComments, 'DVD Special features:' + #13#10 + FullValue); Page.Free; //DisplayResults; end; function GetInfo(Name: string; Page: TStringList): string; var LineNr, BeginPos, EndPos: Integer; Value, Line: string; begin LineNr := FindLine(Name, Page, 0); if LineNr > 0 then begin Line := Page.GetString(LineNr); BeginPos := Pos(': ', Line) + 7; EndPos := Pos('
', Line); Value := Copy(Line, BeginPos, EndPos - BeginPos); HTMLRemoveTags(Value); HTMLDecode(Value); Result := Value; end else Result := ''; end; begin if CheckVersion(3,5,0) then begin MovieName := GetField(fieldOriginalTitle); if MovieName = '' then MovieName := GetField(fieldTranslatedTitle); if Input('Mediadis Import', 'Enter the title of the movie:', MovieName) then begin AnalyzePage('http://www.mediadis.com/products/search.asp?t=1&kw=' + UrlEncode(MovieName) + '&kwt=t&pl=all'); end; end else ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)'); end.