New German Script (Combined OFDb/IMDb Script)

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.
Bad Joker
Posts: 81
Joined: 2002-06-10 12:46:38
Location: Hamburg, Germany
Contact:

New German Script (Combined OFDb/IMDb Script)

Post by Bad Joker »

hey folks

i did a new script for all the german users, with the next update the script should be within the installation package.

it's a combined script which uses first ofdb to get the title and then get there the description and the imdb url, and then all the other stuff from the imdb site.

it gets from ofdb:
-german description
-(german imdb) url

and then from imdb:
-executive producer
-german translated/original title
-director
-actors
-year
-rating (does not round the value anymore, just gets the first number from the x.x value)
-country
-category

if you find any bugs or you just have some suggestion, tell me ;)

http://scorpius.spaceports.com/~badjoke ... Db(DE).ifs

there you can get the script
antp
Site Admin
Posts: 9636
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Re: New German Script (Combined OFDb/IMDb Script)

Post by antp »

Bad Joker wrote: with the next update the script should be within the installation package.
I should did that on Monday, but I forgot, and yesterday I did not had time for that.
It will be done today or Friday ;)
eternal

Post by eternal »

hi

i really would appreciate if u please could implement a function to get "the small movie pic" and the "movie lenght"

anyways, awesome work dude, thx

eternal

PS: ant movie catalog simply owns :)
Bad Joker
Posts: 81
Joined: 2002-06-10 12:46:38
Location: Hamburg, Germany
Contact:

Post by Bad Joker »

hey

you could do that at your own, just add the script parts from the imdb script (pic import and lenght) to my script and voila ;)
eternal

Post by eternal »

well, i did as you said and it works ;)

thx for the small hint, wouldn't have thought of that possibility to edit the script myself

eternal
MasterBlaster

Re: New German Script (Combined OFDb/IMDb Script)

Post by MasterBlaster »

Hi Bad Joker,

I extend your script to a "MasterBlaster OFDb-IMDb (DE)" script.
But I have a problem to extend the script with the "fieldMadiaLabel" Field.
I use this Field for the certificates information
(in Germany like FSK 12 = Free Self Control 12 ) :-)
but every time I run the script, I get an error that the
"fieldMediaLabel" isn't usable.

Do you have any idea ?

MasterBlaster

PS: In the first Script it was an error about the rating.

[quote="Bad Joker"]hey folks

...

if you find any bugs or you just have some suggestion, tell me ;)

...
antp
Site Admin
Posts: 9636
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

If I remember well it is fieldMedia and not fieldMediaLabel

For the rating error, if it comes from IMDB, replace
if Pos('awaiting', Line) = 0 then
by
if Pos('/10', Line) > 0 then
Guest

Post by Guest »

.
Guest

Post by Guest »

So, at first thx for this script. But now I wan't to extend your script with a pic-search. I've add the script part from the imdb script. The URL is: "http://images.amazon.com/". This works fine, but I need the german covers, so I have to connect to "http://eu-images.amazon.com/". But it doesn't function. Do you have an idea, why not?

1 more question:

How I can use "www.darktown.com" for my pics?


thx
Bad Joker
Posts: 81
Joined: 2002-06-10 12:46:38
Location: Hamburg, Germany
Contact:

Post by Bad Joker »

sure is there a way, but please try to understand "how" the imdb script works and then create one for darktown or amazon on yourself, i thing this will be a big piece of work to add that :)

so i hop you understand, why i don't do it...

also i'm wainting to import urls into the movie database instead of saving all images to disk, will be much better ;)
good joker

Post by good joker »

hi
could you add the large pic from the imdb or a german pic (with the german text on it)(equal quality)
Bad Joker
Posts: 81
Joined: 2002-06-10 12:46:38
Location: Hamburg, Germany
Contact:

Post by Bad Joker »

this is really easy

just add the code from the "imdb large" pic script to the "ofdb - imdb" script from me :)


here is the code:

Code: Select all

// Picture
  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;
add it under the "procedure AnalyseIMDBPage(Page: TStringList);"
part
good joker(bad name)

Post by good joker(bad name) »

:grinking: thx
Guest

Post by Guest »

Hi, you're right. I have seen, that it will be a big piece of work to add other cover-pages.

Okay, I'll try it. Now I've add the function to search in amazon.com and imdb.com for pics if the script does not find a pic in ofdb. It's very simple, but for me its really okay, FOR NOW :)

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   *
 *                                                 *
 *     Pic Import by Frau Holle                    *
 *                                                 *
 *  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;
  PicDa : integer;
const
  OFDB_Server = 'http://ofdb.persephone.net-build.de/';
  PicNotAvabOFDB = 'http://www.hsi-infopool.de/zensur/movies/images/film/na.gif';

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;

  // Picture
  LineNr := FindLine('http://www.hsi-infopool.de/zensur/movies/images/film', 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);
      if Value = PicNotAvabOFDB then
      PicDa := 1
       else
       begin
        PicDa := 0;
        GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
       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(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: Integer;
begin

  // Picture
  if PicDa = 1 then
  begin
    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);
      GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
    end;
  end;
  
  // 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;
  
  //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;

  //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;
  



  // 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;
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.
Guest

Post by Guest »

Anonymous wrote:Hi, you're right. I have seen, that it will be a big piece of work to add other cover-pages.

Okay, I'll try it. Now I've add the function to search in amazon.com and imdb.com for pics if the script does not find a pic in ofdb. It's very simple, but for me its really okay, FOR NOW :)

// 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 *
* *
* *
* 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;
PicDa : integer;
const
OFDB_Server = 'http://ofdb.persephone.net-build.de/';
PicNotAvabOFDB = 'http://www.hsi-infopool.de/zensur/movie ... ilm/na.gif';

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;

// Picture
LineNr := FindLine('http://www.hsi-infopool.de/zensur/movies/images/film', 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);
if Value = PicNotAvabOFDB then
PicDa := 1
else
begin
PicDa := 0;
GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
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(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: Integer;
begin

// Picture
if PicDa = 1 then
begin
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);
GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
end;
end;

// 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;

//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;

//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;




// 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;
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.
antp
Site Admin
Posts: 9636
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

I do not know why you quoted your post, I guess I should delete it ? (it takes lots of space on the page :D)
I edited the first of the two post to put the code between

Code: Select all

 tags, to make it more readable.
PS: if you register on the forum you can edit your posts ;)
hansi

Post by hansi »

i wonder if someone please could include a new "get large picture" method, because since imdb lately changed their web page the large picture doesnt work anymore and i dont get the the code from the "large picture beta topic" to work because this script uses imdb and ofdb. i am really sorry to bother, but i am not that good with such scripting stuff, can hardly use notepad.

i hope someone will help me

cu and thx in advance
Bad Joker
Posts: 81
Joined: 2002-06-10 12:46:38
Location: Hamburg, Germany
Contact:

Post by Bad Joker »

just add that beta picture thing under the "//Category" part and set the variables in the "AnalyseIMDBPage" procedure, thats all

if you got problems, ask me via mail
antp
Site Admin
Posts: 9636
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

If you modified the OFDB scripts, can you send me the updated version ? Thanks :)
Guest

Post by Guest »

Hi BadJoker !

First at all a big thank you for the great job you did with this script :grinking:

But I've problems importing the movie "Ali" with Will Smith. Can you give me a hint how I can get the facts of this movie with your script, please ? Typing "Ali" gives to much results... :cry:

Thx & greetings,
Fred.
Post Reply