Page 2 of 3

Posted: 2002-12-29 20:16:56
by Bad Joker
maybe you try to use the normal imdb script and add the german description and the url and the german title manually

here is the ofdb page from ali:

http://ofdb.persephone.net-build.de/vie ... &fid=16271

there is no solution for your problem, it's the way ofdb works, sorry

Posted: 2003-01-03 20:50:41
by berseker
Sorry but my English is not so good, i have a small problem since today with the german database.
I become following mistake. http/ 1.1 403 forbidden.
With the "original script" and also with the scripts here in the post please help me.
All other database are corrected, only ofdb and the combinated ofdb/imdb are mistakes.

Posted: 2003-01-04 01:09:01
by Bad Joker
it seems that the ofdb server is down again, the amount of serverload increased dramatically the last month, so ofdb had several problems

i hope it's fixed again, but it's not a bug in the script, it's just the server

Posted: 2003-01-04 09:13:10
by Guest
@ Bad Joker
Thanks for your answer, i will hope that the problems with the server are only for a few days.

Posted: 2003-01-31 02:16:04
by Bo
Hi!

The Script is very great! THX!!!

I´ve done just a few additions (copy & paste):

- Large Picture from Amazon/IMDB
- Movie-Lenght
- User Comment from IMDB
- 9 Actors
(You can choose the number left to //!!!!!ANZAHL DARSTELLER!!!!!)

Greats,

Bo.

Code: Select all

// GETINFO SCRIPTING
// Combined OFDb / IMDb (DE) import with description from OFDb. All other informations from IMDb

(***************************************************
 *  Movie importation script for:                  *
 *  Online-Filmdatenbank(OFDb), 	                 *
 *   http://www.ofdb.de                            *
 *            and                                  *
 *  Internet Movie Database (IMDb),                *
 *   http://us.imdb.com                            *
 *                                                 *
 *  (c) 2002 Fabian Filipczyk    FFJaro@gmx.de     *
 *                                                 *
 *     Modified by Bad Joker    badjoker@gmx.net   *
 *                                                 *
 *     Modified by Bo                                            *
 *                                                 *
 *  For use with Ant Movie Catalog 3.4.0           *
 *  www.ant.be.tf/moviecatalog ··· www.buypin.com  *
 *                                                 *
 *  The source code of the script can be used in   *
 *  another program only if full credits to        *
 *  script author and a link to Ant Movie Catalog  *
 *  website are given in the About box or in       *
 *  the documentation of the program               *
 ***************************************************)

program OFDB_DE;
var
  MovieName, IMDbURL, GerIMDbDURL: string;
const
  OFDB_Server = 'http://ofdb.persephone.net-build.de/';

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 AnalysePage(Address: string);
var
  Page: TStringList;
  LineNr: Integer;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  if pos('<title>OFDb - Übersicht der Filmdaten</title>', Page.Text) > 0 then
  begin
    AnalyseOFDBPage(Page)
    AnalyseIMDBDPage(Page)
    AnalyseIMDBPage(Page)
    DisplayResults
  end else
  begin
    if pos('Titel:</b><br><br><b>&#149;</b> <i>Keine Ergebnisse</i>', Page.Text) > 0 then
    begin
      ShowMessage('Keine Ergebnisse unter dem Titel zu finden, bitte den Titel des Filmes ändern!');
      Input('OFDb', 'Bitte einen alternativen Titel eingeben :', MovieName);
      AnalysePage(OFDB_Server + 'view.php?page=suchergebnis&SText='+UrlEncode(MovieName)+'&Kat=All');
    end else
    begin
    PickTreeClear;
    LineNr := FindLine('<b>Titel:</b>', Page, 0);
    if LineNr > 0 then
    begin PickTreeAdd('Filme:', '');
      AddMoviesTitles(Page, LineNr);
      if PickTreeExec(Address) then
         AnalysePage(Address);
    end;
    end;
  end;
  Page.Free;
end;

procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
var
  Line: string;
  MovieTitle, MovieAddress: string;
  StartPos, EndPos: Integer;
begin
  Line := Page.GetString(LineNr);
  repeat
    StartPos := pos('<a href=''view.php?page=film&fid=', Line);
    if StartPos > 0 then
    begin
      Delete(Line, 1, StartPos + 8);
      MovieAddress := copy(Line, 1, pos('''>', Line) - 1);
      StartPos := pos('''>', Line) +2;
      MovieTitle := copy(Line, StartPos, pos('</a>', Line) - StartPos);
      HTMLRemoveTags(MovieTitle);
      PickTreeAdd(MovieTitle , OFDB_Server + MovieAddress);
    end;
  until (StartPos < 1);
end;

procedure AnalyseOFDBPage(Page: TStringList);
var
  Line, Temp, Value: string;
  LineNr, BeginPos, EndPos: Integer;
begin

  // Get IMDb URL + Set german IMDb URLs
  begin
    LineNr :=Findline('http://german.imdb.com/Title?', Page, 0);
    Line := Page.GetString(LineNr);
    BeginPos := pos('german.imdb.com/Title?', Line)-7;
    EndPos := pos('target', Line)-2;
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    SetField(fieldURL, Value);
    BeginPos := pos('Title?', Line)+6;
    EndPos := pos('target', Line)-2;
    Temp := copy(Line, BeginPos, EndPos - BeginPos);
    Value := ('http://german.imdb.com/Details?' + Temp);
    GerIMDbDURL := Value;
    Value := ('http://us.imdb.com/Title?' + Temp);
    IMDbURL := Value;
  end;

  // Description
  LineNr := Findline('<b>Inhalt:</b>', Page, 0);
  if LineNr > -1 then
  begin
    LineNr :=Findline('<a href=''view.php?page=inhalt', Page, 0);
    Line := Page.GetString(LineNr);
    BeginPos := pos('<a href=''view.php?page=inhalt', Line)+9;
    EndPos := pos('''><b>[mehr]', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    GetDescriptions(Value);
  end;
end;

procedure GetDescriptions(Address: string);
var
  Line, Temp, Value: string;
  LineNr, BeginPos, EndPos: Integer;
  Page: TStringList;

begin
  Temp:= '';
  Page := TStringList.Create;
  Page.Text := GetPage(OFDB_Server + Address);
  LineNr := FindLine('Eine Inhaltsangabe von', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := pos('</a></b><br><br>', Line) + 16;
    while (pos('<br />', Line) >0) do
         begin
           EndPos := pos('<br />', Line);
           Temp := Temp + copy(Line, BeginPos, EndPos - BeginPos);
           LineNr:=LineNr+1;
           Line:=Page.GetString(LineNr);
           BeginPos:=1;
         end;	
    EndPos := pos('</font></p>', Line);
    Temp:= Temp +  copy(Line, BeginPos, EndPos - BeginPos);
    Value:= Temp;
    SetField(fieldDescription, Value);
  end;
  Page.Free;
end;

procedure AnalyseIMDBDPage(Page: TStringList);
var
  Line, Value, Value2, FullValue, GerTitle, Ger, Temp: string;
  BeginPos, EndPos, LineNr, TempPos: Integer;
begin

  Page.Text := GetPage(GerIMDbDURL);

  //Producer
  LineNr := FindLine('<a name="producers"', Page, 0);
  if LineNr > -1 then
  begin
    FullValue := '';
    EndPos := 0;
    Line := Page.GetString(LineNr);
    BeginPos := Pos('<b class="blackcatheader">Produktion', Line);
    EndPos := Pos('<a name="music_original"', Line);
    if EndPos = 0 then
    begin
    EndPos := Pos('<a name="cinematographers"', Line);
    end;
    Line := copy(Line, BeginPos, EndPos - BeginPos);
    repeat
      BeginPos := Pos('<td valign="top">', Line);
      if BeginPos > 0 then
      begin
        Delete(Line, 1, BeginPos + 25);
        TempPos := Pos('">producer</a>', Line);
        if (TempPos > 0) and (TempPos < Pos('</tr>', Line)) then
        begin
          BeginPos := pos('">', Line) + 2;
          EndPos := pos('</a>', Line);
          if EndPos = 0 then
            EndPos := Pos('</td>', Line);
          Value := copy(Line, BeginPos, EndPos - BeginPos);
          if FullValue <> '' then
            FullValue := FullValue + ', ';
          FullValue := FullValue + Value;
          EndPos := Pos('</td></tr>', Line);
          Delete(Line, 1, EndPos);
        end;
      end else
      begin
        Line := '';
      end;
    until Line = '';
    HTMLDecode(FullValue);
    SetField(fieldProducer, FullValue);
  end;

  // Translated Title
  LineNr := FindLine('<i class="transl">', Page, 0);
  if LineNr > -1 then
    begin
      Ger := '';
      LineNr := LineNr - 1;
      repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);
        if Pos('[de]', Line) or Pos('(Germany)', Line) > 0 then
        begin
        BeginPos := pos('class="transl">', Line) + 14;
        EndPos := pos('[de]', Line);
        Ger := copy(Line, BeginPos, EndPos - BeginPos);
        end;
      until (pos('<b class="ch">', Line) > 0 );
      BeginPos := pos('>', Ger) + 1;
      EndPos := pos('(', Ger) - 1;
      GerTitle := copy(Ger, BeginPos, EndPos - BeginPos);
      HTMLDecode(GerTitle);
      SetField(fieldTranslatedTitle, GerTitle);
    end;
end;

procedure AnalyseIMDBPage(Page: TStringList);
var
  Line, Value, Value2, FullValue: string;
  BeginPos, EndPos, LineNr, nActors: Integer;
  AmazonPage: TStringList;                          //Für großes Bild
  FoundOnAmazon: Boolean;                           //Für großes Bild
  
begin

  // Original Title & Year
  Page.Text := GetPage(IMDbURL);
  LineNr := FindLine('<title>', Page, 0);
  Line := Page.GetString(LineNr);
  if LineNr > -1 then
  begin
    BeginPos := pos('<title>', Line);
    if BeginPos > 0 then
      BeginPos := BeginPos + 7;
      EndPos := pos('(', Line);
    if EndPos = 0 then
      EndPos := Length(Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos - 1);
    HTMLDecode(Value);
    SetField(fieldOriginalTitle, Value);
    BeginPos := pos('(', Line) + 1;
    if BeginPos > 0 then
    begin
      EndPos := pos(')', Line);
      Value := copy(Line, BeginPos, EndPos - BeginPos);
      SetField(fieldYear, Value);
    end;
  end;

  // Rating
  LineNr := FindLine('User Rating:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr + 4);
    if Pos('/10', Line) > 0 then
    begin
      Line := Page.GetString(LineNr + 4);
      BeginPos := pos('<b>', Line) + 3;
      EndPos := BeginPos + 1;
      Value := copy(Line, BeginPos, EndPos - BeginPos);
      SetField(fieldRating, Value);
    end;
  end;

  // Director
  LineNr := FindLine('Directed by', Page, 0);
  if LineNr > -1 then
  begin
    FullValue := '';
    Line := Page.GetString(LineNr + 1);
    repeat
      BeginPos := pos('">', Line) + 2;
      EndPos := pos('</a>', Line);
      Value := copy(Line, BeginPos, EndPos - BeginPos);
      if (Value <> '(more)') and (Value <> '') then
      begin
        if FullValue <> '' then
          FullValue := FullValue + ', ';
        FullValue := FullValue + Value;
      end;
      Delete(Line, 1, EndPos);
    until Pos('</a>', Line) = 0;
    HTMLDecode(FullValue);
    SetField(fieldDirector, FullValue);
  end;

 (* // Actors
  LineNr := FindLine('Cast overview', Page, 0);
  if LineNr = -1 then
    LineNr := FindLine('cast overview', Page, 0);
  if LineNr = -1 then
    LineNr := FindLine('Credited cast', Page, 0);
  if LineNr = -1 then
    LineNr := FindLine('Complete credited cast', Page, 0);
  if LineNr > -1 then
  begin
    FullValue := '';
    Line := Page.GetString(LineNr);
    repeat
      BeginPos := Pos('<td valign="top">', Line);
      if BeginPos > 0 then
      begin
        Delete(Line, 1, BeginPos);
        Line := copy(Line, 25, Length(Line));
        BeginPos := pos('">', Line) + 2;
        EndPos := pos('</a>', Line);
        if EndPos = 0 then
          EndPos := Pos('</td>', Line);
        Value := copy(Line, BeginPos, EndPos - BeginPos);
        if (Value <> '(more)') and (Value <> '') then
        begin
          BeginPos := pos('.... </td><td valign="top">', Line);
          if BeginPos > 0 then
          begin
            EndPos := pos('</td></tr>', Line);
            BeginPos := BeginPos + 27;
            Value2 := copy(Line, BeginPos, EndPos - BeginPos);
            if Value2 <> '' then
            begin
              Value := Value + ' (als ' + Value2 + ')';
            end;
          end;
          if FullValue <> '' then
            FullValue := FullValue + ', ';
          FullValue := FullValue + Value;
        end;
        EndPos := Pos('</td></tr>', Line);
        Delete(Line, 1, EndPos);
      end else
      begin
        Line := '';
      end;
    until Line = '';
    HTMLDecode(FullValue);
    SetField(fieldActors, FullValue);
  end;  *)
  
  // Actors
  LineNr := FindLine('ast overview', Page, 0);
  if LineNr = -1 then
    LineNr := FindLine('redited cast', Page, 0);
  if LineNr > -1 then
  begin
    FullValue := '';
    Line := Page.GetString(LineNr);
    nActors := 0;
    repeat
      BeginPos := Pos('<td valign="top">', Line);
      if BeginPos > 0 then
      begin
        Delete(Line, 1, BeginPos);
        Line := copy(Line, 25, Length(Line));
        BeginPos := pos('">', Line) + 2;
        EndPos := pos('</a>', Line);
        if EndPos = 0 then
          EndPos := Pos('</td>', Line);
        Value := copy(Line, BeginPos, EndPos - BeginPos);
        if (Value <> '(more)') and (Value <> '') then
        begin
          BeginPos := pos('.... </td><td valign="top">', Line);
          if BeginPos > 0 then
          begin
            EndPos := pos('</td></tr>', Line);
            BeginPos := BeginPos + 27;
            Value2 := copy(Line, BeginPos, EndPos - BeginPos);
            if Value2 <> '' then
            begin
              Value := Value + ' (as ' + Value2 + ')';   //!!!!!als ODER as!!!!!
            end;
          end;
          if FullValue <> '' then
            FullValue := FullValue + ', ';
          FullValue := FullValue + Value;
          nActors := nActors + 1;
        end;
        EndPos := Pos('</td></tr>', Line);
        Delete(Line, 1, EndPos);
      end else
      begin
        Line := '';
      end;
    until (Line = '') or (nActors >= 9);           //!!!!!ANZAHL DARSTELLER!!!!!
    HTMLDecode(FullValue);
    SetField(fieldActors, FullValue);
  end;

  //Country
  LineNr := FindLine('Country:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    BeginPos := pos('/">', Line) + 3;
    EndPos := pos('</a>', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    HTMLDecode(Value);
    SetField(fieldCountry, Value);
  end;
  
//--------------------------EINGEFÜGT-------------------------------------------
  // Length
  LineNr := FindLine('Runtime:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    EndPos := pos(' min', Line);
    if EndPos = 0 then
      EndPos := pos('  /', Line);
    if EndPos = 0 then
      EndPos := Length(Line);
    if Pos(':', Line) < EndPos then
      BeginPos := Pos(':', Line) + 1
    else
      BeginPos := 1;
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    SetField(fieldLength, Value);
  end;

  // Comments
  LineNr := FindLine('<b>Summary:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Value := '';
    repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);
      EndPos := Pos('</blockquote>', Line);
      if EndPos = 0 then
        EndPos := Length(Line)
      else
        EndPos := EndPos - 2;
      Value := Value + Copy(Line, 1, EndPos) + ' ';
    until Pos('</blockquote>', Line) > 0;
    HTMLDecode(Value);
    Value := StringReplace(Value, '<br>', #13#10);
    Value := StringReplace(Value, #13#10+' ', #13#10);
    SetField(fieldComments, Value);
  end;
  
    // Picture
  FoundOnAmazon := False;
  LineNr := FindLine('title="DVD available at Amazon.com"', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := Pos('href="', Line) + 5;
    Delete(Line, 1, BeginPos);
    EndPos := Pos('"', Line);
    Value := Copy(Line, 1, EndPos - 1);
    AmazonPage := TStringList.Create;
    AmazonPage.Text := GetPage('http://us.imdb.com' + Value);
    LineNr := FindLine('<b>1.', AmazonPage, 0);
    if LineNr = -1 then
    begin
      LineNr := FindLine('img src="http://images.amazon.com/images/P/', AmazonPage, 0);
      if LineNr > -1 then
      begin
        Line := AmazonPage.GetString(LineNr);
        BeginPos := Pos('img src="http://images.amazon.com/images/P/', Line) + 8;
        Delete(Line, 1, BeginPos);
        EndPos := Pos('"', Line);
        Value := Copy(Line, 1, EndPos - 1);
        Value := StringReplace(Value, 'TZZZZZZZ', 'LZZZZZZZ');
        GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
        FoundOnAmazon := True;
      end;
    end else
    begin
      LineNr := FindLine('http://images.amazon.com/images/P/', AmazonPage, LineNr);
      Line := AmazonPage.GetString(LineNr);
      BeginPos := Pos('src="', Line) + 4;
      Delete(Line, 1, BeginPos);
      EndPos := Pos('"', Line);
      Value := Copy(Line, 1, EndPos - 1);
      Value := StringReplace(Value, 'THUMBZZZ', 'LZZZZZZZ');
      GetPicture(Value, False);
      FoundOnAmazon := True;
    end;
    AmazonPage.Free;
  end;

  if not FoundOnAmazon then
  begin
    {
       not found on Amazon, so taking what's available directly on IMDB.
       if we are lucky, a picture from amazon but directly linked in the page
    }
    LineNr := FindLine('<img alt="cover" align="left" src="http://ia.imdb.com/media/imdb/', Page, 0);
    if LineNr < 0 then
      LineNr := FindLine('<img alt="cover" align="left" src="http://posters.imdb.com/', Page, 0);
    if LineNr < 0 then
      LineNr := FindLine('<img alt="cover" align="left" src="http://images.amazon.com/', Page, 0);
    if LineNr > -1 then
    begin
      Line := Page.GetString(LineNr);
      BeginPos := pos('src="', Line) + 4;
      Delete(Line, 1, BeginPos);
      EndPos := pos('"', Line);
      Value := copy(Line, 1, EndPos - 1);
      Value := StringReplace(Value, 'MZZZZZZZ', 'LZZZZZZZ'); // change URL to get the Large instead of Small image
      GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
    end;
  end;
  
//------------------------------------------------------------------------------

  //Category
  LineNr := FindLine('Genre:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    BeginPos := pos('/">', Line) + 3;
    EndPos := pos('</a>', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    HTMLDecode(Value);
    SetField(fieldCategory, Value);
  end;
end;

begin
  if CheckVersion(3,4,0) then
  begin
    MovieName := GetField(fieldTranslatedTitle);
    if MovieName = '' then
      MovieName := GetField(fieldOriginalTitle);
    if (MovieName <> '') or Input('OFDb', 'Bitte Titel eingeben :', MovieName) then
    begin
      AnalysePage(OFDB_Server + 'view.php?page=suchergebnis&SText='+UrlEncode(MovieName)+'&Kat=All');
    end;
  end else
    ShowMessage('Dieses Script benötigt eine neuere Version von Ant Movie Catalog (mindestens Version 3.4.0)');
end.
[/code]

Posted: 2003-01-31 02:46:56
by Bad Joker
thx ;)

but i don't need lenght, because my files have the lenght in their...

the rest is not important for me... just for the lazy asses ;)

thx

Posted: 2003-02-02 18:28:36
by Guest
Hi !

The script is really great but a lot of movies don't have any picture after using the script. I think the problem is imdb/ofdb which don't have pictures for all movies...
Is there a way to import a picture anyway...? Perhaps there is a small script which I can use for all the movies without picture...?

Many thanks and greetings,
Fred.

Posted: 2003-03-23 00:26:49
by Guest
is it possible to let this script download the german large images from amazon. what do i have to change for this?

Posted: 2003-03-23 10:11:13
by antp
The IMDB script has been updated, so somebody will have to update this script too...

Posted: 2003-03-23 10:53:11
by Guest
Could anybody please tell me the necessary modifications? Ofdb/Imdb does not work since today...

Thank you,
L.

Posted: 2003-03-23 13:34:03
by Bad Joker
what is not working?

i will correct that then

Posted: 2003-03-23 21:37:33
by Guest
Hi BadJoker,
everything is working fine. It was an internal Problem this morning for a couple of hours on ofdb-database.

Ciao,
L.

Posted: 2003-03-30 09:04:22
by LordChip
I want to add german comments. Is there any possibility to do that.

Posted: 2003-03-30 18:27:30
by Bad Joker
maybe there is a way from getting the code from the ofdb script and add it into this one?

Posted: 2003-04-05 20:45:24
by Reh
is it possible to combine this script with the "filmposter-archiv.de" script?
to get the movie infos and a big movie image, not this small imdb things :/
i know theres a amazon-solution posted, but i prefer filmposter-archiv.de, the pictures are better there..

ive tried it, but got everytime type mismatch and doesnt find my error :)

i hope someone who know what to do have 5 min to add this for me (and others? :) ) into the script

and lordchip what you mean exactly? german comments in the script?
with "// german blablabla" then
or the comments under the movie description/plot?
thats a little bit harder then, cause 1. it is everytime a external page on ofdb.de and 2. there are too many comments, cause they does not have staff who can do "better" comments. every user can make his own comment and i dont think you want 40 different weird comments, perhaps even from people which havent seen the movie :)

--Reh--

Posted: 2003-04-05 21:24:24
by antp
I really have to make a better system for version 4.0 for the scripts, to allow to combine scripts without modify them :D

Posted: 2003-04-06 17:55:39
by Reh
sounds good :)

--Reh--

Posted: 2004-12-07 14:55:49
by Guest
The script no longer imports descriptions from OFDb (IMDb part still works well).
I tried to fix the script with parts of the recently updated OFDb template but scripting just doesn't seem to be my world. So, I'd be happy if somebody who is more skilled could do the job. TIA

OFDb / IMDb Script Update

Posted: 2004-12-16 22:50:55
by VisualMAx
Just downloaded this great tool...
But this OFDb + IMDb Script wasn't working...
Overviewed this forum... nothing found... so done it by myself...

If anyone find this usefull... here fetch it...
// GETINFO SCRIPTING
// Combined OFDb / IMDb (DE)
// Deutscher Titel / Kleines Bild von OFDb
// Rest IMDb (DE)

(***************************************************
* Movie importation script for: *
* Online-Filmdatenbank(OFDb), *
* http://www.ofdb.de *
* and *
* Internet Movie Database (IMDb), *
* http://us.imdb.com *
* *
* (c) 2002 Fabian Filipczyk FFJaro@gmx.de *
* *
* Modified by Bad Joker badjoker@gmx.net *
* *
* @16.10.2004 *
* Modified by VisualMAx (at)gmail.com *
* *
* For use with Ant Movie Catalog 3.3.0 *
* www.antp.be/software/moviecatalog *
* *
* 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. *
***************************************************)

program OFDB_DE;
var
MovieName, IMDbURL, GerIMDbDURL: 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 AnalysePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if pos('<title>OFDb - Übersicht der Filmdaten</title>', Page.Text) > 0 then
begin
AnalyseOFDBPage(Page)
AnalyseIMDBDPage(Page)
AnalyseIMDBPage(Page)
DisplayResults
end else
begin
if pos('Titel:</b><br><br><b>&#149;</b> <i>Keine Ergebnisse</i>', Page.Text) > 0 then
begin
ShowMessage('Keine Ergebnisse unter dem Titel zu finden, bitte den Titel des Filmes ändern!');
if (MovieName <> '') or Input('OFDb', 'Bitte einen alternativen Titel eingeben :', MovieName) then
begin
AnalysePage('http://www.ofdb.de/view.php?page=sucher ... +'&Kat=All');
end;
end else
begin
PickTreeClear;
LineNr := FindLine('<b>Titel:</b>', Page, 0);
if LineNr > 0 then
begin PickTreeAdd('Filme:', '');
AddMoviesTitles(Page, LineNr);
if PickTreeExec(Address) then
AnalysePage(Address);
end;
end;
end;
Page.Free;
end;

procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
var
Line: string;
MovieTitle, MovieAddress: string;
StartPos, EndPos: Integer;
begin
Line := Page.GetString(LineNr);
repeat
StartPos := pos('<a href=''view.php?page=film&fid=', Line);
if StartPos > 0 then
begin
Delete(Line, 1, StartPos + 8);
MovieAddress := copy(Line, 1, pos('''>', Line) - 1);
StartPos := pos('''>', Line) +2;
MovieTitle := copy(Line, StartPos, pos('</a>', Line) - StartPos);
HTMLRemoveTags(MovieTitle);
PickTreeAdd(MovieTitle , 'http://www.ofdb.de/' + MovieAddress);
end;
until (StartPos < 1);
end;

procedure AnalyseOFDBPage(Page: TStringList);
var
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
begin

// Get IMDb URL + Set german IMDb URLs
begin
LineNr :=Findline('http://german.imdb.com/Title?', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('http://german.imdb.com/Title?', Line);
EndPos := pos('" target', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldURL, Value);
BeginPos := pos('Title?', Line)+6;
EndPos := pos('" target', Line);
Temp := copy(Line, BeginPos, EndPos - BeginPos);
Value := ('http://german.imdb.com/Details?' + Temp);
GerIMDbDURL := Value;
Value := ('http://us.imdb.com/Title?' + Temp);
IMDbURL := Value;
end;

// Original & Translated Title
LineNr := FindLine('Originaltitel:</font>', Page, 0);
if LineNr > -1 then
begin
LineNr:= LineNr+2;
Line := Page.GetString(LineNr);
BeginPos := pos('class="Daten"><b>', Line) + 17;
EndPos := pos('</b></font>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldOriginalTitle, Value);
LineNr := Findline('sans-serif" size="3"><b>', Page, 0);
if LineNr > -1 then
begin
Line:= Page.GetString(LineNr);
BeginPos := pos('sans-serif" size="3"><b>',Line) +24;
Endpos := pos('</b></font></td>',Line);
Value := copy(Line,BeginPos, Endpos-Beginpos);
SetField(fieldTranslatedTitle,Value);
end;
end;

// Picture
LineNr := FindLine('images/film/', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<img src="', Line) + 10;
if BeginPos > 10 then
begin
EndPos := pos(' alt=', Line)-1;
Value := copy(Line, BeginPos, EndPos - BeginPos);
Temp := 'http://www.ofdb.de/'+Value;
GetPicture(Temp, False);
end;
end;

// Description
LineNr := Findline('<b>Inhalt:</b>', Page, 0);
if LineNr > -1 then
begin
LineNr := Findline('<a href="view.php?page=inhalt', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="view.php?page=inhalt', Line)+9;
EndPos := pos('"><b>[mehr]', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
GetDescriptions(Value);
end;
end;

procedure GetDescriptions(Address: string);
var
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
Page: TStringList;

begin
Temp:= '';
Page := TStringList.Create;
Page.Text := GetPage('http://www.ofdb.de/' + Address);
LineNr := FindLine('Eine Inhaltsangabe von', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('</a></b><br><br>', Line) + 16;
while (pos('<br />', Line) >0) do
begin
EndPos := pos('<br />', Line);
Temp := Temp + copy(Line, BeginPos, EndPos - BeginPos);
LineNr:=LineNr+1;
Line:=Page.GetString(LineNr);
BeginPos:=1;
end;
EndPos := pos('</font></p>', Line);
Temp:= Temp + copy(Line, BeginPos, EndPos - BeginPos);
Value:= Temp;
SetField(fieldDescription, Value);
end;
Page.Free;
end;

procedure AnalyseIMDBDPage(Page: TStringList);
var
Line, Value, Value2, FullValue, GerTitle, Ger, Temp: string;
BeginPos, EndPos, LineNr, TempPos: Integer;
begin

Page.Text := GetPage(GerIMDbDURL);

//Producer
LineNr := FindLine('<a name="producers"', Page, 0);
if LineNr > -1 then
begin
FullValue := '';
EndPos := 0;
Line := Page.GetString(LineNr);
BeginPos := Pos('<b class="blackcatheader">Produktion', Line);
EndPos := Pos('<a name="music_original"', Line);
if EndPos = 0 then
begin
EndPos := Pos('<a name="cinematographers"', Line);
end;
Line := copy(Line, BeginPos, EndPos - BeginPos);
repeat
BeginPos := Pos('<td valign="top">', Line);
if BeginPos > 0 then
begin
Delete(Line, 1, BeginPos + 25);
TempPos := Pos('">producer</a>', Line);
if (TempPos > 0) and (TempPos < Pos('</tr>', Line)) then
begin
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
if EndPos = 0 then
EndPos := Pos('</td>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
if FullValue <> '' then
FullValue := FullValue + ', ';
FullValue := FullValue + Value;
EndPos := Pos('</td></tr>', Line);
Delete(Line, 1, EndPos);
end;
end else
begin
Line := '';
end;
until Line = '';
HTMLDecode(FullValue);
SetField(fieldProducer, FullValue);
end;
end;

procedure AnalyseIMDBPage(Page: TStringList);
var
Line, Value, Value2, FullValue: string;
BeginPos, EndPos, LineNr: Integer;
begin

// Original Title & Year
Page.Text := GetPage(IMDbURL);
LineNr := FindLine('<title>', Page, 0);
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('<title>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 7;
EndPos := pos('(', Line);
if EndPos = 0 then
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos - 1);
HTMLDecode(Value);
SetField(fieldOriginalTitle, Value);
BeginPos := pos('(', Line) + 1;
if BeginPos > 0 then
begin
EndPos := pos(')', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldYear, Value);
end;
end;

// Rating
LineNr := FindLine('User Rating:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 4);
if Pos('awaiting', Line) = 0 then
begin
Line := Page.GetString(LineNr + 4);
BeginPos := pos('<b>', Line) + 3;
EndPos := BeginPos + 1;
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldRating, Value);
end;
end;

// Director
LineNr := FindLine('Directed by', Page, 0);
if LineNr > -1 then
begin
FullValue := '';
Line := Page.GetString(LineNr + 1);
repeat
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
if (Value <> '(more)') and (Value <> '') then
begin
if FullValue <> '' then
FullValue := FullValue + ', ';
FullValue := FullValue + Value;
end;
Delete(Line, 1, EndPos);
until Pos('</a>', Line) = 0;
HTMLDecode(FullValue);
SetField(fieldDirector, FullValue);
end;

// Actors
LineNr := FindLine('Cast overview', Page, 0);
if LineNr = -1 then
LineNr := FindLine('cast overview', Page, 0);
if LineNr = -1 then
LineNr := FindLine('Credited cast', Page, 0);
if LineNr = -1 then
LineNr := FindLine('Complete credited cast', Page, 0);
if LineNr > -1 then
begin
FullValue := '';
Line := Page.GetString(LineNr);
repeat
BeginPos := Pos('<td valign="top">', Line);
if BeginPos > 0 then
begin
Delete(Line, 1, BeginPos);
Line := copy(Line, 25, Length(Line));
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
if EndPos = 0 then
EndPos := Pos('</td>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
if (Value <> '(more)') and (Value <> '') then
begin
BeginPos := pos('.... </td><td valign="top">', Line);
if BeginPos > 0 then
begin
EndPos := pos('</td></tr>', Line);
BeginPos := BeginPos + 27;
Value2 := copy(Line, BeginPos, EndPos - BeginPos);
if Value2 <> '' then
begin
Value := Value + ' (als ' + Value2 + ')';
end;
end;
if FullValue <> '' then
FullValue := FullValue + ', ';
FullValue := FullValue + Value;
end;
EndPos := Pos('</td></tr>', Line);
Delete(Line, 1, EndPos);
end else
begin
Line := '';
end;
until Line = '';
HTMLDecode(FullValue);
SetField(fieldActors, FullValue);
end;

//if 1 = 0 then // For de-activating english comments
begin
// Comments
LineNr := FindLine('<b>Summary:</b>', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
EndPos := Pos('</blockquote>', Line);
if EndPos = 0 then
EndPos := Length(Line)
else
EndPos := EndPos - 1;
Value := Value + Copy(Line, 1, EndPos) + ' ';
until Pos('</blockquote>', Line) > 0;
HTMLDecode(Value);
Value := StringReplace(Value, '<br>', #13#10);
Value := StringReplace(Value, #13#10+' ', #13#10);
SetField(fieldComments, Value);
end;
end;

// Length
LineNr := FindLine('Runtime:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 1);
EndPos := pos(' min', Line);
if EndPos = 0 then
EndPos := pos(' /', Line);
if EndPos = 0 then
EndPos := Length(Line);
if Pos(':', Line) < EndPos then
BeginPos := Pos(':', Line) + 1
else
BeginPos := 1;
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldLength, Value);
end;

// Language
LineNr := FindLine('Language:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 1);
BeginPos := pos('/">', Line) + 3;
EndPos := pos('</a>', Line);
if EndPos = 0 then
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldLanguages, Value);
end;

//Country
LineNr := FindLine('Country:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 1);
BeginPos := pos('/">', Line) + 3;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
if pos('</a> / <a ', Line) > 2 then
begin
Line := copy(Line, pos('</a> / <a ', Line) + 8, Length(Line));
BeginPos := pos('/">', Line) + 3;
EndPos := pos('</a>', Line);
Value := Value + ' / ' + copy(Line, BeginPos, EndPos - BeginPos);
end;
HTMLDecode(Value);
SetField(fieldCountry, Value);
end;

//Category
LineNr := FindLine('Genre:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 1);
BeginPos := pos('/">', Line) + 3;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
HTMLDecode(Value);
SetField(fieldCategory, Value);
end;
end;

begin
if CheckVersion(3,3,0) then
begin
MovieName := GetField(fieldTranslatedTitle);
if MovieName = '' then
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
begin
Input('OFDb', 'Bitte Titel eingeben :', MovieName)
AnalysePage('http://www.ofdb.de/view.php?page=sucher ... +'&Kat=All');
end else
begin
AnalysePage('http://www.ofdb.de/view.php?page=sucher ... +'&Kat=All');
end;
end else
ShowMessage('Dieses Script benötigt eine neuere Version von Ant Movie Catalog (mindestens Version 3.3.0)');
end.

OFDb / IMDb Script Update

Posted: 2004-12-16 22:55:30
by VisualMAx
@MOD: Woopsy... used "quote" and not "code" please delete my prev. post... sorry :cry:


Just downloaded this great tool...
But this OFDb + IMDb Script wasn't working...
Overviewed this forum... nothing found... so done it by myself...

If anyone find this usefull... here fetch it...

Code: Select all

// GETINFO SCRIPTING
// Combined OFDb / IMDb (DE)
// Deutscher Titel / Kleines Bild von OFDb
// Rest IMDb (DE)

(***************************************************
 *  Movie importation script for:                  *
 *  Online-Filmdatenbank(OFDb)  	                 *
 *   http://www.ofdb.de                            *
 *            and                                  *
 *  Internet Movie Database (IMDb)                 *
 *   http://us.imdb.com                            *
 *                                                 *
 *  (c) 2002 Fabian Filipczyk    FFJaro@gmx.de     *
 *                                                 *
 *     Modified by Bad Joker    badjoker@gmx.net   *
 *                                                 *
 *     @16.10.2004                                 *
 *     Modified by VisualMAx    (at)gmail.com      *
 *                                                 *
 *  For use with Ant Movie Catalog 3.3.0           *
 *  www.antp.be/software/moviecatalog              *
 *                                                 *
 *  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.                     *
 ***************************************************)

program OFDB_DE;
var
  MovieName, IMDbURL, GerIMDbDURL: 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 AnalysePage(Address: string);
var
  Page: TStringList;
  LineNr: Integer;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  if pos('<title>OFDb - Übersicht der Filmdaten</title>', Page.Text) > 0 then
  begin
    AnalyseOFDBPage(Page)
    AnalyseIMDBDPage(Page)
    AnalyseIMDBPage(Page)
    DisplayResults
  end else
  begin
    if pos('Titel:</b><br><br><b>&#149;</b> <i>Keine Ergebnisse</i>', Page.Text) > 0 then
    begin
      ShowMessage('Keine Ergebnisse unter dem Titel zu finden, bitte den Titel des Filmes ändern!');
      if (MovieName <> '') or Input('OFDb', 'Bitte einen alternativen Titel eingeben :', MovieName) then
        begin
        AnalysePage('http://www.ofdb.de/view.php?page=suchergebnis&SText='+UrlEncode(MovieName)+'&Kat=All');
        end;
  end else
  begin
    PickTreeClear;
    LineNr := FindLine('<b>Titel:</b>', Page, 0);
    if LineNr > 0 then
    begin PickTreeAdd('Filme:', '');
      AddMoviesTitles(Page, LineNr);
      if PickTreeExec(Address) then
         AnalysePage(Address);
    end;
    end;
  end;
  Page.Free;
end;

procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
var
  Line: string;
  MovieTitle, MovieAddress: string;
  StartPos, EndPos: Integer;
begin
  Line := Page.GetString(LineNr);
  repeat
    StartPos := pos('<a href=''view.php?page=film&fid=', Line);
    if StartPos > 0 then
    begin
      Delete(Line, 1, StartPos + 8);
      MovieAddress := copy(Line, 1, pos('''>', Line) - 1);
      StartPos := pos('''>', Line) +2;
      MovieTitle := copy(Line, StartPos, pos('</a>', Line) - StartPos);
      HTMLRemoveTags(MovieTitle);
      PickTreeAdd(MovieTitle , 'http://www.ofdb.de/' + MovieAddress);
    end;
  until (StartPos < 1);
end;

procedure AnalyseOFDBPage(Page: TStringList);
var
  Line, Temp, Value: string;
  LineNr, BeginPos, EndPos: Integer;
begin

  // Get IMDb URL + Set german IMDb URLs
  begin
    LineNr :=Findline('http://german.imdb.com/Title?', Page, 0);
    Line := Page.GetString(LineNr);
    BeginPos := pos('http://german.imdb.com/Title?', Line);
    EndPos := pos('" target', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    SetField(fieldURL, Value);
    BeginPos := pos('Title?', Line)+6;
    EndPos := pos('" target', Line);
    Temp := copy(Line, BeginPos, EndPos - BeginPos);
    Value := ('http://german.imdb.com/Details?' + Temp);
    GerIMDbDURL := Value;
    Value := ('http://us.imdb.com/Title?' + Temp);
    IMDbURL := Value;
  end;

  // Original & Translated Title
  LineNr := FindLine('Originaltitel:</font>', Page, 0);
  if LineNr > -1 then
  begin
    LineNr:= LineNr+2;
    Line := Page.GetString(LineNr);
    BeginPos := pos('class="Daten"><b>', Line) + 17;
    EndPos := pos('</b></font>', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    SetField(fieldOriginalTitle, Value);
    LineNr := Findline('sans-serif" size="3"><b>', Page, 0);
    if LineNr > -1 then
    begin
      Line:= Page.GetString(LineNr);
      BeginPos := pos('sans-serif" size="3"><b>',Line) +24;
      Endpos :=  pos('</b></font></td>',Line);
      Value := copy(Line,BeginPos, Endpos-Beginpos);
      SetField(fieldTranslatedTitle,Value);
    end;
  end;
  
  // Picture
  LineNr := FindLine('images/film/', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := pos('<img src="', Line) + 10;
    if BeginPos > 10 then
    begin
      EndPos := pos(' alt=', Line)-1;
      Value := copy(Line, BeginPos, EndPos - BeginPos);
      Temp := 'http://www.ofdb.de/'+Value;
      GetPicture(Temp, False);
    end;
  end;

  // Description
  LineNr := Findline('<b>Inhalt:</b>', Page, 0);
  if LineNr > -1 then
  begin
    LineNr := Findline('<a href="view.php?page=inhalt', Page, 0);
    Line := Page.GetString(LineNr);
    BeginPos := pos('<a href="view.php?page=inhalt', Line)+9;
    EndPos := pos('"><b>[mehr]', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    GetDescriptions(Value);
  end;
end;

procedure GetDescriptions(Address: string);
var
  Line, Temp, Value: string;
  LineNr, BeginPos, EndPos: Integer;
  Page: TStringList;

begin
  Temp:= '';
  Page := TStringList.Create;
  Page.Text := GetPage('http://www.ofdb.de/' + Address);
  LineNr := FindLine('Eine Inhaltsangabe von', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := pos('</a></b><br><br>', Line) + 16;
    while (pos('<br />', Line) >0) do
         begin
           EndPos := pos('<br />', Line);
           Temp := Temp + copy(Line, BeginPos, EndPos - BeginPos);
           LineNr:=LineNr+1;
           Line:=Page.GetString(LineNr);
           BeginPos:=1;
         end;	
    EndPos := pos('</font></p>', Line);
    Temp:= Temp +  copy(Line, BeginPos, EndPos - BeginPos);
    Value:= Temp;
    SetField(fieldDescription, Value);
  end;
  Page.Free;
end;

procedure AnalyseIMDBDPage(Page: TStringList);
var
  Line, Value, Value2, FullValue, GerTitle, Ger, Temp: string;
  BeginPos, EndPos, LineNr, TempPos: Integer;
begin

  Page.Text := GetPage(GerIMDbDURL);

  //Producer
  LineNr := FindLine('<a name="producers"', Page, 0);
  if LineNr > -1 then
  begin
    FullValue := '';
    EndPos := 0;
    Line := Page.GetString(LineNr);
    BeginPos := Pos('<b class="blackcatheader">Produktion', Line);
    EndPos := Pos('<a name="music_original"', Line);
    if EndPos = 0 then
    begin
    EndPos := Pos('<a name="cinematographers"', Line);
    end;
    Line := copy(Line, BeginPos, EndPos - BeginPos);
    repeat
      BeginPos := Pos('<td valign="top">', Line);
      if BeginPos > 0 then
      begin
        Delete(Line, 1, BeginPos + 25);
        TempPos := Pos('">producer</a>', Line);
        if (TempPos > 0) and (TempPos < Pos('</tr>', Line)) then
        begin
          BeginPos := pos('">', Line) + 2;
          EndPos := pos('</a>', Line);
          if EndPos = 0 then
            EndPos := Pos('</td>', Line);
          Value := copy(Line, BeginPos, EndPos - BeginPos);
          if FullValue <> '' then
            FullValue := FullValue + ', ';
          FullValue := FullValue + Value;
          EndPos := Pos('</td></tr>', Line);
          Delete(Line, 1, EndPos);
        end;
      end else
      begin
        Line := '';
      end;
    until Line = '';
    HTMLDecode(FullValue);
    SetField(fieldProducer, FullValue);
  end;
end;

procedure AnalyseIMDBPage(Page: TStringList);
var
  Line, Value, Value2, FullValue: string;
  BeginPos, EndPos, LineNr: Integer;
begin

  // Original Title & Year
  Page.Text := GetPage(IMDbURL);
  LineNr := FindLine('<title>', Page, 0);
  Line := Page.GetString(LineNr);
  if LineNr > -1 then
  begin
    BeginPos := pos('<title>', Line);
    if BeginPos > 0 then
      BeginPos := BeginPos + 7;
      EndPos := pos('(', Line);
    if EndPos = 0 then
      EndPos := Length(Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos - 1);
    HTMLDecode(Value);
    SetField(fieldOriginalTitle, Value);
    BeginPos := pos('(', Line) + 1;
    if BeginPos > 0 then
    begin
      EndPos := pos(')', Line);
      Value := copy(Line, BeginPos, EndPos - BeginPos);
      SetField(fieldYear, Value);
    end;
  end;

  // Rating
  LineNr := FindLine('User Rating:', Page, 0);
  if LineNr > -1 then
  begin
      Line := Page.GetString(LineNr + 4);
      if Pos('awaiting', Line) = 0 then
      begin
      Line := Page.GetString(LineNr + 4);
      BeginPos := pos('<b>', Line) + 3;
      EndPos := BeginPos + 1;
      Value := copy(Line, BeginPos, EndPos - BeginPos);
      SetField(fieldRating, Value);
      end;
  end;

  // Director
  LineNr := FindLine('Directed by', Page, 0);
  if LineNr > -1 then
  begin
    FullValue := '';
    Line := Page.GetString(LineNr + 1);
    repeat
      BeginPos := pos('">', Line) + 2;
      EndPos := pos('</a>', Line);
      Value := copy(Line, BeginPos, EndPos - BeginPos);
      if (Value <> '(more)') and (Value <> '') then
      begin
        if FullValue <> '' then
          FullValue := FullValue + ', ';
        FullValue := FullValue + Value;
      end;
      Delete(Line, 1, EndPos);
    until Pos('</a>', Line) = 0;
    HTMLDecode(FullValue);
    SetField(fieldDirector, FullValue);
  end;

  // Actors
  LineNr := FindLine('Cast overview', Page, 0);
  if LineNr = -1 then
    LineNr := FindLine('cast overview', Page, 0);
  if LineNr = -1 then
    LineNr := FindLine('Credited cast', Page, 0);
  if LineNr = -1 then
    LineNr := FindLine('Complete credited cast', Page, 0);
  if LineNr > -1 then
  begin
    FullValue := '';
    Line := Page.GetString(LineNr);
    repeat
      BeginPos := Pos('<td valign="top">', Line);
      if BeginPos > 0 then
      begin
        Delete(Line, 1, BeginPos);
        Line := copy(Line, 25, Length(Line));
        BeginPos := pos('">', Line) + 2;
        EndPos := pos('</a>', Line);
        if EndPos = 0 then
          EndPos := Pos('</td>', Line);
        Value := copy(Line, BeginPos, EndPos - BeginPos);
        if (Value <> '(more)') and (Value <> '') then
        begin
          BeginPos := pos('.... </td><td valign="top">', Line);
          if BeginPos > 0 then
          begin
            EndPos := pos('</td></tr>', Line);
            BeginPos := BeginPos + 27;
            Value2 := copy(Line, BeginPos, EndPos - BeginPos);
            if Value2 <> '' then
            begin
              Value := Value + ' (als ' + Value2 + ')';
            end;
          end;
          if FullValue <> '' then
            FullValue := FullValue + ', ';
          FullValue := FullValue + Value;
        end;
        EndPos := Pos('</td></tr>', Line);
        Delete(Line, 1, EndPos);
      end else
      begin
        Line := '';
      end;
    until Line = '';
    HTMLDecode(FullValue);
    SetField(fieldActors, FullValue);
  end;

  //if 1 = 0 then // For de-activating english comments
  begin
  // Comments
  LineNr := FindLine('<b>Summary:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Value := '';
    repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);
      EndPos := Pos('</blockquote>', Line);
      if EndPos = 0 then
        EndPos := Length(Line)
      else
        EndPos := EndPos - 1;
      Value := Value + Copy(Line, 1, EndPos) + ' ';
    until Pos('</blockquote>', Line) > 0;
    HTMLDecode(Value);
    Value := StringReplace(Value, '<br>', #13#10);
    Value := StringReplace(Value, #13#10+' ', #13#10);
    SetField(fieldComments, Value);
  end;
  end;

  // Length
  LineNr := FindLine('Runtime:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    EndPos := pos(' min', Line);
    if EndPos = 0 then
      EndPos := pos('  /', Line);
    if EndPos = 0 then
      EndPos := Length(Line);
    if Pos(':', Line) < EndPos then
      BeginPos := Pos(':', Line) + 1
    else
      BeginPos := 1;
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    SetField(fieldLength, Value);
  end;

  // Language
  LineNr := FindLine('Language:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    BeginPos := pos('/">', Line) + 3;
    EndPos := pos('</a>', Line);
    if EndPos = 0 then
      EndPos := Length(Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    SetField(fieldLanguages, Value);
  end;
  
  //Country
  LineNr := FindLine('Country:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    BeginPos := pos('/">', Line) + 3;
    EndPos := pos('</a>', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    if pos('</a> / <a ', Line) > 2 then
    begin
      Line := copy(Line, pos('</a> / <a ', Line) + 8, Length(Line));
      BeginPos := pos('/">', Line) + 3;
      EndPos := pos('</a>', Line);
      Value := Value + ' / ' + copy(Line, BeginPos, EndPos - BeginPos);
    end;
    HTMLDecode(Value);
    SetField(fieldCountry, Value);
  end;
  
  //Category
  LineNr := FindLine('Genre:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    BeginPos := pos('/">', Line) + 3;
    EndPos := pos('</a>', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    HTMLDecode(Value);
    SetField(fieldCategory, Value);
  end;
end;

begin
  if CheckVersion(3,3,0) then
  begin
    MovieName := GetField(fieldTranslatedTitle);
    if MovieName = '' then
      MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
    begin
      Input('OFDb', 'Bitte Titel eingeben :', MovieName)
      AnalysePage('http://www.ofdb.de/view.php?page=suchergebnis&SText='+UrlEncode(MovieName)+'&Kat=All');
    end else
    begin
      AnalysePage('http://www.ofdb.de/view.php?page=suchergebnis&SText='+UrlEncode(MovieName)+'&Kat=All');
    end;
  end else
    ShowMessage('Dieses Script benötigt eine neuere Version von Ant Movie Catalog (mindestens Version 3.3.0)');
end.