[EN] Made a script for AdultFilmDatabase

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
Post Reply
Hein
Posts: 2
Joined: 2006-02-13 15:31:46

[EN] Made a script for AdultFilmDatabase

Post by Hein »

I have made a script for the site http://www.adultfilmdatabase.com.

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.
Kalynuik
Posts: 16
Joined: 2005-09-28 14:00:05
Location: Canada

adultfilmdatabase

Post by Kalynuik »

I recently tried this script with 3.5.0.2 and it asks for Title, then brings up foudn Titles, I choose one, click OK, it then appears to collect data/downloading then nothing, AMC seems to hang, I can choose STOP but then of course the script stops, but if left nothing happens, is anyone else having this problem?
Hein
Posts: 2
Joined: 2006-02-13 15:31:46

Post by Hein »

The script was made with the following version:

MovieCatalog.exe: versie 3.5.0.2 (gemaakt op 29-5-2005 11:51:40)
AMCExchange.dll: versie 1.0.1.6 (gemaakt op 26-6-2004 23:39:22)
AMCReport.exe: versie 1.0.2.2 (gemaakt op 15-1-2005 16:13:56)
MediaInfo.dll: versie 0.6.0.0 (gemaakt op 18-5-2005 22:45:58)

I have imported 12 movies and my brother 20 and the script never failed. Maybe there was something wrong with the site at the moment you imported. You can also try to see at which statement the script hangs by using the editor
- F6 to open the Scenario windows
- Editor to see the source
- put the cursor at line 144 (AnalyseMoviePage(Address))
- Press F4 to run the script until the cursor is reached
- Give a title and pick a result from the list
- The script stops at the cursor position
- Use F8 to step through each line of code to see where the script hangs
antp
Site Admin
Posts: 9636
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Or simply notify for which movie title search does the script hang :D
Post Reply