It works for me so I hope it works for you too. It might not be the nicest script ever written but it works
I shall also mail it to antp.
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Hein Hees
Title=AdultFilmDatabase.com
Description=AdultFilmDatabase.com import script
Site=www.adultfilmdatabase.com
Language=EN
Version=1.0
Requires=3.5.0
Comments=MovieMeter.nl script by Antoine Potten and IMDB script by Antoine Potten and KaraGarga served as an example for this script
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 AdultFilmDatabase;
uses
StringUtils1;
var
MovieName: string;
procedure AnalyzeMoviePage(Address: string);
var
PageText, Line, Value: string;
begin
PageText := GetPage(Address);
// URL
SetField(fieldURL, Address);
// Picture
Value := 'http://www.adultfilmdatabase.com/Graphics/Boxes'+TextBetween(PageText, '<img SRC="/Graphics/Boxes', '" ');
if Value <> '' then
begin
GetPicture(Value);
end;
// Length
Value := TextBetween(PageText, 'Length:</td>', '</td>');
// Line := RemainingText;
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldLength, Value);
// Studio
Value := TextBetween(PageText, 'Studio:</td>', '</a>');
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldProducer, Value);
// title & year
Value := TextBetween(PageText, 'Year:</td>', '</td>');
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldYear, Value);
Value := TextBetween(PageText, '<h2>', '</h2>');
HTMLDecode(Value);
SetField(fieldOriginalTitle, Value);
// Director
Value := TextBetween(PageText, 'Director:</td>', '</td>');
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldDirector, Value);
// Genre
Line := TextBetween(PageText, 'Genre:</td>', '</tr>');
Value := TextBetween(Line, '100%">', '</td>');
HTMLRemoveTags(Value);
HTMLDecode(Value);
//ShowMessage(IntToStr(Ord(Copy(Value, 1, 1))));
Value := Stringreplace(Value,' ','');
Value := Stringreplace(Value,#9,'');
Value := Stringreplace(Value,#13#10,'');
SetField(fieldCategory, 'Erotic - '+Value);
// Description
Value := TextBetween(PageText, 'COLSPAN="2"><BR>', '</td>');
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldDescription, Value);
// Actors
Line := PageText;
Value := '';
While pos('ActorID', Line) > 0 do
begin
if length(Value)>0 then Value := Value + ', ';
Line := TextBetween(Line, 'ActorID', '</U></a><br>');
Line := '<a HREF="'+Line;
HTMLRemoveTags(Line);
HTMLDecode(Line);
Value := Value + Line;
Line := RemainingText;
end;
SetField(fieldActors, Value);
// Rating
Value := TextBetween(Line, 'Rating:</td>', '</td>');
HTMLRemoveTags(Value);
If Value = 'no rating - add your comment' then Value := '';
if Value <> '' then
Value := StringReplace(FloatToStr(StrToFloat(StringReplace(Value, ',', '.')) * 2), ',', '.');
SetField(fieldRating, Value);
end;
procedure AnalyzeResultsPage(Address: string);
var
Page: string;
TotalPage: string;
MovieAddress: string;
TempAddress: string;
MovieTitle: string;
MorePages: boolean;
begin
Page := GetPage(Address);
TotalPage := Page;
MorePages := True;
if (pos('<h2>Search Results for', Page) = 0) and (pos('No results were found', Page) = 0) then // found one movie
begin
AnalyzeMoviePage(Address);
end else
begin
if Pos('<td>No results were found', Page) = 0 then
begin
// more movies found
PickTreeClear;
PickTreeAdd('Zoekresultaten voor ' + MovieName, '');
While (MorePages = True) do
begin
Page := TextBetween(Page, '<tr CLASS="bgLG">', '</tr>');
while Pos('a HREF=', Page) > 0 do
begin
MovieAddress := 'http://www.adultfilmdatabase.com'+TextBetween(Page, 'HREF="', '">');
TempAddress := TextBetween(Page, 'HREF="', '">');
MovieTitle := TextBetween(Page, TempAddress+'">', '</a><BR>');
Page := RemainingText;
HTMLRemoveTags(MovieTitle);
HTMLDecode(MovieTitle);
PickTreeAdd(Trim(MovieTitle), MovieAddress);
end;
if Pos('Next',TotalPage) >0 then
Begin
Page := TextBetween(TotalPage, '<td CLASS="px11" ALIGN="right" WIDTH="30%">', '</a>');
Address := 'http://www.adultfilmdatabase.com'+TextBetween(Page, 'HREF="', '">');
Page := GetPage(Address);
TotalPage := Page;
MorePages := True;
end else
MorePages := False;
end;
// if user picks a movie from the results list, import movie details
if PickTreeExec(Address) then
AnalyzeMoviePage(Address);
end
else
ShowMessage('No movie found for this search');
end;
end;
begin
if CheckVersion(3,5,0) then
begin
if StringUtils1_Version >= 2 then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
if Input('AdultFilmDatabase.com Import', 'Give the title of the movie:', MovieName) then
begin
AnalyzeResultsPage('http://www.adultfilmdatabase.com/index.cfm?Action=Lookup&Find='+UrlEncode(MovieName)+'&SearchType=Video');
end;
end
else
ShowMessage('The file "StringUtils1.pas" is outdated, please find a new version of it (at least version 2)');
end
else
ShowMessage('This script requires a new version of Ant Movie Catalog (at least version 3.5.0)');
end.