For all the Germans out there (and also other people)

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:

For all the Germans out there (and also other people)

Post by Bad Joker »

i h4X0r3d the imdb script a bit :lol:

the changes:
-adds the german title into the translated title field (sometimes it add some more then it should be, maybe someone can help me, read below code on)
-adds all excutive producers to the producer field, same like the actors with comma
-adds the german imdb url into the url field (german.imdb.com/...)
-translated the questions in the script to german (type in title, wrong version, etc.)

does not add following fields anymore (i don't need them)
-lenght (i got it already from the avi(s) )
-language (it always differs for me, so i add it manualy)
-comment (i don't need them, therefore i have the imdb link and sometimes own comments)

so here it is:

Code: Select all

// GETINFO SCRIPTING
// IMDB (DE) import, with translated title / excutive producer and without lenght, language and comment

(****************************************************
 *  Movie importation script for:                   *
 *      IMDB (DE), http://german.imdb.com           *
 *                                                  *
 *  (c) 2002 Antoine Potten    antoine@buypin.com   *
 *  Improvements made by Danny Falkov               *
 *  German Additions and Modifications              *
 *  made by Bad Joker		badjoker@gmx.net    *
 *                                                  *
 *  For use with Ant Movie Catalog 3.2.1 or greater *
 *  www.ant.be.tf/moviecatalog ··· www.buypin.com   *
 ***************************************************)

program IMDb;
var
  MovieName: string;

function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
var
  i: Integer;
begin
  result := -1;
  if StartAt < 0 then
    StartAt := 0;
  for i := StartAt to List.Count-1 do
    if Pos(Pattern, List.GetString(i)) <> 0 then
    begin
      result := i;
      Break;
    end;
end;

procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  LineNr: Integer;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  if pos('<TITLE>IMDb', Page.Text) = 0 then
  begin
    SetField(fieldURL, Address);
    AnalyzeMoviePage(Page)
  end else
  begin
    PickTreeClear;
    LineNr := 0;
    LineNr := FindLine('<H2><A NAME="top">Most popular searches</A></H2>', Page, LineNr);
    if LineNr > -1 then
    begin
      PickTreeAdd('Most popular searches', '');
      AddMoviesTitles(Page, LineNr);
    end;
    LineNr := FindLine('<H2><A NAME="mov">Movies</A></H2>', Page, LineNr);
    if LineNr > -1 then
    begin
      PickTreeAdd('Movies', '');
      AddMoviesTitles(Page, LineNr);
    end;
    LineNr := FindLine('<H2><A NAME="tvm">TV-Movies</A></H2>', Page, LineNr);
    if LineNr > -1 then
    begin
      PickTreeAdd('TV-Movies', '');
      AddMoviesTitles(Page, LineNr);
    end;
    LineNr := FindLine('<H2><A NAME="vid">Made for video</A></H2>', Page, LineNr);
    if LineNr > -1 then
    begin
      PickTreeAdd('Made for video', '');
      AddMoviesTitles(Page, LineNr);
    end;
    if PickTreeExec(Address) then
      AnalyzePage(Address);
  end;
  Page.Free;
end;

procedure AnalyzeMoviePage(Page: TStringList);
var
  Line, Value, FullValue, CastValue, ProValue, URL, Ger: string;
  LineNr: Integer;
  BeginPos, EndPos, URLStart, URLEnd: Integer;
begin

  //Original Title & Year
  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;

  //URL
  LineNr := FindLine('<BASE HREF="', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    URLStart := pos('/Title?', Line) + 7;
    URLEnd := pos('">', Line);
    Value := copy(Line, URLStart, URLEnd - URLStart);
    SetField(fieldURL, 'http://german.imdb.com/Title?' + Value);
  end;
  
  // Rating
  LineNr := FindLine('User Rating:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := pos('<B>', Line) + 3;
    Value := IntToStr(Round(StrToInt(StrGet(Line, BeginPos), 0) + (StrToInt(StrGet(Line, BeginPos + 2), 0) / 10)));
    SetField(fieldRating, Value);
  end;

  //Director
  LineNr := FindLine('Directed by', Page, 0);
  if LineNr > -1 then
  begin
    FullValue := '';
    repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);
      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;
    until (pos('<BR><BR>', Line) > 0) or (LineNr >= Page.Count-1) or (Line = '<BR>');
    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('Complete credited cast', Page, 0);
  if LineNr > -1 then
  begin
    CastValue := '';
    repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);
      if pos('<TD VALIGN="TOP">', Line) > 0 then
      begin
        Line := copy(Line, 25, Length(Line));
        BeginPos := pos('">', Line) + 2;
        EndPos := pos('</A>', Line);
        Value := copy(Line, BeginPos, EndPos - BeginPos);
        if (Value <> '(more)') and (Value <> '') then
        begin
          if CastValue <> '' then
            CastValue := CastValue + ', ';
          CastValue := CastValue + Value;
        end;
      end else
      begin
        Line := '';
      end;
    until Line = '';
    HTMLDecode(CastValue);
    SetField(fieldActors, CastValue);
  end;

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

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

  //Description
  LineNr := FindLine('Plot Summary:', Page, 0);
  if LineNr < 1 then
    LineNr := FindLine('Plot Outline:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := pos('</B>', Line) + 4;
    EndPos := pos('<A HREF', Line);
    if EndPos < 1 then
      Line := Line + Page.GetString(LineNr+1);
    EndPos := pos('<A HREF', Line);
    PickListClear;
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    HTMLDecode(Value);
    PickListAdd(Value);
    BeginPos := pos('/Plot?', Line);
    EndPos := pos('"> (more)', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    GetDescriptions(Value);
    Value := '';
    if PickListExec('Wähle eine Beschreibung für "' + MovieName + '"', Value) then
      SetField(fieldDescription, Value);
  end;

  //Translated Title
  LineNr := FindLine('<BASE HREF="', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    URLStart := pos('/Title?', Line) + 7;
    URLEnd := pos('">', Line);
    URL := copy(Line, URLStart, URLEnd - URLStart);
    Page.Text := GetPage('http://german.imdb.com/Title?' + URL);
    LineNr := FindLine('Alternativ:', Page, 0);
    if LineNr > -1 then
    begin
      Ger := '';
      repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);
        if Pos('[de]', Line) or Pos('(Germany)', Line) > 0 then
        begin
        BeginPos := pos('CLASS="transl">', Line) + 15;
        EndPos := pos('[de]', Line) - 18;
        Ger := copy(Line, BeginPos, EndPos - BeginPos);
        end;
      until (pos('</TD></TR>', Line) > 0 );
      SetField(fieldTranslatedTitle, Ger);
    end;
  end;

  //Producer
  LineNr := FindLine('<BASE HREF="', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    URLStart := pos('/Title?', Line) + 7;
    URLEnd := pos('">', Line);
    URL := copy(Line, URLStart, URLEnd - URLStart);
    Page.Text := GetPage('http://us.imdb.com/Details?' + URL);
    LineNr := FindLine('Produced by', Page, 0);
    if LineNr > -1 then
    begin
      ProValue := '';
      repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);
      BeginPos := pos('">', Line) + 2;
      EndPos := pos('</A>', Line);
        if Pos('executive producer', Line) > 0 then
        begin
        Value := copy(Line, BeginPos, EndPos - BeginPos);
        if (Value <> '(more)') and (Value <> '') then
          begin
          if ProValue <> '' then
            ProValue := ProValue + ', ';
            ProValue := ProValue + Value;
          end;
        end;
      until (pos('</TABLE>', Line) > 0 );
    HTMLDecode(ProValue);
    HTMLRemoveTags(ProValue);
    SetField(fieldProducer, ProValue);
  end;
  end;

  DisplayResults;
end;

procedure GetDescriptions(Address: string);
var
  Line, Value: string;
  LineNr: Integer;
  BeginPos, EndPos: Integer;
  Page: TStringList;
begin
  Page := TStringList.Create;
  Page.Text := GetPage('http://us.imdb.com' + Address);
  LineNr := FindLine('<P CLASS="plotpar">', Page, 0);
  while LineNr > -1 do
  begin
    Value := '';
    repeat
      Line := Page.GetString(LineNr);
      BeginPos := pos('"plotpar">', Line);
      if BeginPos > 0 then
        BeginPos := BeginPos + 10
      else
        BeginPos := 1;
      EndPos := pos('</P>', Line);
      if EndPos < 1 then
        EndPos := Length(Line) + 1;
      if Value <> '' then
        Value := Value + ' ';
      Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
      LineNr := LineNr + 1;
    until (pos('</P>', Line) > 0) or (LineNr = Page.Count);
    PickListAdd(Value);
    LineNr := FindLine('<P CLASS="plotpar">', Page, LineNr);
  end;
  Page.Free;
end;

procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
var
  Line: string;
  MovieTitle, MovieAddress: string;
  StartPos: Integer;
begin
  repeat
    LineNr := LineNr + 1;
    Line := Page.GetString(LineNr);
    StartPos := pos('="', Line);
    if StartPos > 0 then
    begin
      Startpos := Startpos + 2;
      MovieAddress := copy(Line, StartPos, pos('">', Line) - StartPos);
      StartPos := pos('">', Line) + 2;
      MovieTitle := copy(Line, StartPos, pos('</A>', Line) - StartPos);
      HTMLDecode(Movietitle);
      PickTreeAdd(MovieTitle, 'http://us.imdb.com' + MovieAddress);
    end;
  until pos('</OL>', Line) > 0;
end;

begin
  if CheckVersion(3,2,1) then
  begin
    MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);
    if Input('IMDb Import', 'Geben den Titel des Filmes ein:', MovieName) then
    begin
//      AnalyzePage('http://us.imdb.com/Tsearch?title='+UrlEncode(MovieName)+'&restrict=Movies+only');
      AnalyzePage('http://us.imdb.com/Tsearch?title='+UrlEncode(MovieName));
    end;
  end else
    ShowMessage('Dieses Script benötigt eine neuere Version des Ant Movie Catalog (Version 3.2.1 oder höher)');
end.
here you get the file here:
http://badjoker.cdaweb.de/IMDB_(DE).ifs

maybe antoine will add it into the next release

so here is now my problem:
when adding the german title, i reads the full title from the html source from:
CLASS="transl"> to [de]

the title in the browser looks like that:
"Faculty - Trau keinem Lehrer (1999) (Germany) [de]"

after that i kill the rest, but it must look like that, because i only subtract 18 chars if the title looks like that, it won't work properly:

"Conan, der Zerstörer (1984) (West Germany) [de]"

can anyone tell me, how i can not subtract but can kill the "(1984) (West Germany) [de]" part?

there must be a way to kill it instead of only substract, it's just all in () and the [de] after the title

feedback would be nice, maybe i did some mistakes, i hate coding and this was the first coding in this language from me ;)
Last edited by Bad Joker on 2002-08-09 17:13:34, edited 1 time in total.
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Nice, if you want I can include it with the setup package.

To remove the () [] stuff, you can simply remove what's after the first "(" :

Code: Select all

BeginPos := Pos('(', Value);
if BeginPos > 0 then
  Delete(Value, BeginPos, Length(Value));
Bad Joker
Posts: 81
Joined: 2002-06-10 12:46:38
Location: Hamburg, Germany
Contact:

Post by Bad Joker »

doesn't work this way... :(

he will copy then all titles from the site

Code: Select all

//Translated Title
  LineNr := FindLine('<BASE HREF="', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    URLStart := pos('/Title?', Line) + 7;
    URLEnd := pos('">', Line);
    URL := copy(Line, URLStart, URLEnd - URLStart);
    Page.Text := GetPage('http://german.imdb.com/Title?' + URL);
    LineNr := FindLine('Alternativ:', Page, 0);
    if LineNr > -1 then
    begin
      Ger := '';
      repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);
        if Pos('[de]', Line) or Pos('(Germany)', Line) > 0 then
        begin
        BeginPos := pos('CLASS="transl">', Line) + 15;
        EndPos := pos('[de]', Line) - 4;
        BeginPos := pos('(', Value);
          if BeginPos > 0 then
          Delete(Value, BeginPos, Length(Value));
        Ger := copy(Line, BeginPos, EndPos - BeginPos);
        end;
      until (pos('</TD></TR>', Line) > 0 );
      SetField(fieldTranslatedTitle, Ger);
    end;
  end;
Bad Joker
Posts: 81
Joined: 2002-06-10 12:46:38
Location: Hamburg, Germany
Contact:

got it

Post by Bad Joker »

HOORAY for double post :p
Last edited by Bad Joker on 2002-08-09 17:12:52, edited 1 time in total.
Bad Joker
Posts: 81
Joined: 2002-06-10 12:46:38
Location: Hamburg, Germany
Contact:

got it

Post by Bad Joker »

got the clue :D

here is the corrected version:

Code: Select all

// GETINFO SCRIPTING
// IMDB (DE) import, with translated title / excutive producer and without lenght, language and comment

(****************************************************
 *  Movie importation script for:                   *
 *      IMDB (DE), http://german.imdb.com           *
 *                                                  *
 *  (c) 2002 Antoine Potten    antoine@buypin.com   *
 *  Improvements made by Danny Falkov               *
 *  German Additions and Modifications              *
 *  made by Bad Joker		badjoker@gmx.net    *
 *                                                  *
 *  For use with Ant Movie Catalog 3.2.1 or greater *
 *  www.ant.be.tf/moviecatalog ··· www.buypin.com   *
 ***************************************************)

program IMDb;
var
  MovieName: string;

function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
var
  i: Integer;
begin
  result := -1;
  if StartAt < 0 then
    StartAt := 0;
  for i := StartAt to List.Count-1 do
    if Pos(Pattern, List.GetString(i)) <> 0 then
    begin
      result := i;
      Break;
    end;
end;

procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  LineNr: Integer;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  if pos('<TITLE>IMDb', Page.Text) = 0 then
  begin
    SetField(fieldURL, Address);
    AnalyzeMoviePage(Page)
  end else
  begin
    PickTreeClear;
    LineNr := 0;
    LineNr := FindLine('<H2><A NAME="top">Most popular searches</A></H2>', Page, LineNr);
    if LineNr > -1 then
    begin
      PickTreeAdd('Most popular searches', '');
      AddMoviesTitles(Page, LineNr);
    end;
    LineNr := FindLine('<H2><A NAME="mov">Movies</A></H2>', Page, LineNr);
    if LineNr > -1 then
    begin
      PickTreeAdd('Movies', '');
      AddMoviesTitles(Page, LineNr);
    end;
    LineNr := FindLine('<H2><A NAME="tvm">TV-Movies</A></H2>', Page, LineNr);
    if LineNr > -1 then
    begin
      PickTreeAdd('TV-Movies', '');
      AddMoviesTitles(Page, LineNr);
    end;
    LineNr := FindLine('<H2><A NAME="vid">Made for video</A></H2>', Page, LineNr);
    if LineNr > -1 then
    begin
      PickTreeAdd('Made for video', '');
      AddMoviesTitles(Page, LineNr);
    end;
    if PickTreeExec(Address) then
      AnalyzePage(Address);
  end;
  Page.Free;
end;

procedure AnalyzeMoviePage(Page: TStringList);
var
  Line, Value, FullValue, CastValue, ProValue, URL, Ger, GerTitle: string;
  LineNr: Integer;
  BeginPos, EndPos, URLStart, URLEnd: Integer;
begin

  //Original Title & Year
  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;

  //URL
  LineNr := FindLine('<BASE HREF="', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    URLStart := pos('/Title?', Line) + 7;
    URLEnd := pos('">', Line);
    Value := copy(Line, URLStart, URLEnd - URLStart);
    SetField(fieldURL, 'http://german.imdb.com/Title?' + Value);
  end;
  
  // Rating
  LineNr := FindLine('User Rating:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := pos('<B>', Line) + 3;
    Value := IntToStr(Round(StrToInt(StrGet(Line, BeginPos), 0) + (StrToInt(StrGet(Line, BeginPos + 2), 0) / 10)));
    SetField(fieldRating, Value);
  end;

  //Director
  LineNr := FindLine('Directed by', Page, 0);
  if LineNr > -1 then
  begin
    FullValue := '';
    repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);
      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;
    until (pos('<BR><BR>', Line) > 0) or (LineNr >= Page.Count-1) or (Line = '<BR>');
    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('Complete credited cast', Page, 0);
  if LineNr > -1 then
  begin
    CastValue := '';
    repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);
      if pos('<TD VALIGN="TOP">', Line) > 0 then
      begin
        Line := copy(Line, 25, Length(Line));
        BeginPos := pos('">', Line) + 2;
        EndPos := pos('</A>', Line);
        Value := copy(Line, BeginPos, EndPos - BeginPos);
        if (Value <> '(more)') and (Value <> '') then
        begin
          if CastValue <> '' then
            CastValue := CastValue + ', ';
          CastValue := CastValue + Value;
        end;
      end else
      begin
        Line := '';
      end;
    until Line = '';
    HTMLDecode(CastValue);
    SetField(fieldActors, CastValue);
  end;

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

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

  //Description
  LineNr := FindLine('Plot Summary:', Page, 0);
  if LineNr < 1 then
    LineNr := FindLine('Plot Outline:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := pos('</B>', Line) + 4;
    EndPos := pos('<A HREF', Line);
    if EndPos < 1 then
      Line := Line + Page.GetString(LineNr+1);
    EndPos := pos('<A HREF', Line);
    PickListClear;
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    HTMLDecode(Value);
    PickListAdd(Value);
    BeginPos := pos('/Plot?', Line);
    EndPos := pos('"> (more)', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    GetDescriptions(Value);
    Value := '';
    if PickListExec('Wähle eine Beschreibung für "' + MovieName + '"', Value) then
      SetField(fieldDescription, Value);
  end;

  //Translated Title
  LineNr := FindLine('<BASE HREF="', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    URLStart := pos('/Title?', Line) + 7;
    URLEnd := pos('">', Line);
    URL := copy(Line, URLStart, URLEnd - URLStart);
    Page.Text := GetPage('http://german.imdb.com/Title?' + URL);
    LineNr := FindLine('Alternativ:', Page, 0);
    if LineNr > -1 then
    begin
      Ger := '';
      repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);
        if Pos('[de]', Line) or Pos('(Germany)', Line) > 0 then
        begin
        BeginPos := pos('CLASS="transl">', Line) + 15;
        EndPos := pos('[de]', Line);
        Ger := copy(Line, BeginPos, EndPos - BeginPos);
        end;
      until (pos('</TD></TR>', Line) > 0 );
      BeginPos := pos('', Ger);
      EndPos := pos('(', Ger) -2;
      GerTitle := copy(Ger, BeginPos, EndPos - BeginPos);
      SetField(fieldTranslatedTitle, GerTitle);
    end;
  end;

  //Producer
  LineNr := FindLine('<BASE HREF="', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    URLStart := pos('/Title?', Line) + 7;
    URLEnd := pos('">', Line);
    URL := copy(Line, URLStart, URLEnd - URLStart);
    Page.Text := GetPage('http://us.imdb.com/Details?' + URL);
    LineNr := FindLine('Produced by', Page, 0);
    if LineNr > -1 then
    begin
      ProValue := '';
      repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);
      BeginPos := pos('">', Line) + 2;
      EndPos := pos('</A>', Line);
        if Pos('executive producer', Line) > 0 then
        begin
        Value := copy(Line, BeginPos, EndPos - BeginPos);
        if (Value <> '(more)') and (Value <> '') then
          begin
          if ProValue <> '' then
            ProValue := ProValue + ', ';
            ProValue := ProValue + Value;
          end;
        end;
      until (pos('</TABLE>', Line) > 0 );
    HTMLDecode(ProValue);
    HTMLRemoveTags(ProValue);
    SetField(fieldProducer, ProValue);
  end;
  end;

  DisplayResults;
end;

procedure GetDescriptions(Address: string);
var
  Line, Value: string;
  LineNr: Integer;
  BeginPos, EndPos: Integer;
  Page: TStringList;
begin
  Page := TStringList.Create;
  Page.Text := GetPage('http://us.imdb.com' + Address);
  LineNr := FindLine('<P CLASS="plotpar">', Page, 0);
  while LineNr > -1 do
  begin
    Value := '';
    repeat
      Line := Page.GetString(LineNr);
      BeginPos := pos('"plotpar">', Line);
      if BeginPos > 0 then
        BeginPos := BeginPos + 10
      else
        BeginPos := 1;
      EndPos := pos('</P>', Line);
      if EndPos < 1 then
        EndPos := Length(Line) + 1;
      if Value <> '' then
        Value := Value + ' ';
      Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
      LineNr := LineNr + 1;
    until (pos('</P>', Line) > 0) or (LineNr = Page.Count);
    PickListAdd(Value);
    LineNr := FindLine('<P CLASS="plotpar">', Page, LineNr);
  end;
  Page.Free;
end;

procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
var
  Line: string;
  MovieTitle, MovieAddress: string;
  StartPos: Integer;
begin
  repeat
    LineNr := LineNr + 1;
    Line := Page.GetString(LineNr);
    StartPos := pos('="', Line);
    if StartPos > 0 then
    begin
      Startpos := Startpos + 2;
      MovieAddress := copy(Line, StartPos, pos('">', Line) - StartPos);
      StartPos := pos('">', Line) + 2;
      MovieTitle := copy(Line, StartPos, pos('</A>', Line) - StartPos);
      HTMLDecode(Movietitle);
      PickTreeAdd(MovieTitle, 'http://us.imdb.com' + MovieAddress);
    end;
  until pos('</OL>', Line) > 0;
end;

begin
  if CheckVersion(3,2,1) then
  begin
    MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);
    if Input('IMDb Import', 'Geben den Titel des Filmes ein:', MovieName) then
    begin
//      AnalyzePage('http://us.imdb.com/Tsearch?title='+UrlEncode(MovieName)+'&restrict=Movies+only');
      AnalyzePage('http://us.imdb.com/Tsearch?title='+UrlEncode(MovieName));
    end;
  end else
    ShowMessage('Dieses Script benötigt eine neuere Version des Ant Movie Catalog (Version 3.2.1 oder höher)');
end.
also downloadbale here:
http://badjoker.cdaweb.de/IMDB_(DE).ifs
sengir
Posts: 5
Joined: 2002-08-05 22:41:40

Post by sengir »

All your improvements are fine ! I don't know any script tricks, I'm only an end user but I appreciate your work :p Maybe someone will do the same for the french alternate :p (antp ?).

Tell me one thing Bad Joker, when you improve the script, do you manualy update each entry ? (movie name choosing, description,...) You've a big DB is quite boring. But you've maybe find the solution for automaticaly update only some fileds (like rating, alternate title, category) basing the url definied in your entry ?

Thx for your codes
Bad Joker
Posts: 81
Joined: 2002-06-10 12:46:38
Location: Hamburg, Germany
Contact:

Post by Bad Joker »

you can do that automatically

just delete the description entry from the script and then select scripting in the menue (tools) and mark all your movies and then he will add all entrys he'll find automatically, just the selection of the movie you have to do, that is impossible to add to the script ;)
Guest

Post by Guest »

Thanks, but if it should be possible to avoid this selection of movie title if the script is basing on the url in your DB ... Even if title selection is rather easy, if you have a DB of more than 1200 movies... OUCH

:hihi:


See ya
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

if you already have the URL, Instead of this:

Code: Select all

  MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);
    if Input('IMDb Import', 'Geben den Titel des Filmes ein:', MovieName) then
    begin
       AnalyzePage('http://us.imdb.com/Tsearch?title='+UrlEncode(MovieName));
    end; 
just put this :

Code: Select all

     AnalyzePage(GetField(fieldURL)
suchus

Script for other german movie database?

Post by suchus »

Hi there,
I tried Bad Jokers Script, and it works fine.
Unfortunately the imported comments on a movie are in english.

Normally I'm using OFDb http://www.ofdb.de/view.php?page=start to gather information (in german language) on movies.
Now my question - would it be difficult to write a script to import data from this database? Couldn't you try to write another great script for OFDb, Bad Joker? I would really appreciate it to get a script for the data import from OFDb, and I'm sure all the many other OFDb useres would be more than happy as well.

I'm looking forward to hear what you're thinking about a script for OFDb.
Bad Joker
Posts: 81
Joined: 2002-06-10 12:46:38
Location: Hamburg, Germany
Contact:

Post by Bad Joker »

hehe, man i didn't wrote this script, i just tweaked it a bit to fit my needs ;)

i will write a script for germans, but then i will write one for amazon.de, because i think it's much better, never looked at ofdm, have to check it out

this isn't that difficult, you just have to look how this script works and then tweak it for your needs, maybe you try it, i will do this in the next time for amazon, but i need some spare time for that ;)
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Something to know when you test your script (I do not remember if I already said that, but it is in the help file somewhere) :
instead of Page.Text := GetPage(Address) you can do Page.LoadFromFile('c:\page.html'); for example, where page.html is the webbage of a movie on imdb that you saved. So you do not have to download the page from imdb with the script each time you try the script.
suchus

Post by suchus »

@ Bad Joker,

a script for Amazon??? Why for Amazon?
For me as a Horror Movie fan it would be quite disappointing to use Amazon.de as datasource, because they offer only FSK 16 Movies. A search at Amazon would automatically exclude all the great FSK 18, and uncut movies.

I think a script for OFDb would make much more sense, because they have such a huge database (probably bigger than IMDb). It doesn't matter if it's a low budget amateur production or a blockbuster, they have'em all in their database. Thousands of users can't be wrong!

Please check out OFDb (http://www.ofdb.de/view.php?page=start), and you'll see how great it is.
Bad Joker, please think about spending time on a script for Amazon, and try to write one for OFDb instead - pleeeaase!!! Unfortunately I don't know how to change the script, else I would have done it immediately for OFDb.

Cheers,
suchus
sengir
Posts: 5
Joined: 2002-08-05 22:41:40

Post by sengir »

antp wrote:if you already have the URL, Instead of this:

Code: Select all

  MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);
    if Input('IMDb Import', 'Geben den Titel des Filmes ein:', MovieName) then
    begin
       AnalyzePage('http://us.imdb.com/Tsearch?title='+UrlEncode(MovieName));
    end; 
just put this :

Code: Select all

     AnalyzePage(GetField(fieldURL)
Dooh, thx for the hand .. I try it and doesn't work just because of a ")" missing in the code and me, the end user, I found it alone :grinking: lol

The update works fine now, thak you antp
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Yes I forgot a ")" :o

suchus >> to create a script for OFDB it will not simply be a modification of IMDB script, but a complete rewrite, since the site is completely different.
suchus
Posts: 12
Joined: 2002-08-11 12:18:58
Location: Germany

Post by suchus »

@antp

Doesn't sound too good that the script has to be completely rewritten for OFDb. :(
However, me and all the other OFDb users keep our fingers crossed, that maybe one day there'll be someone with the skills, and enough spare time to write a script.

Cheers,
suchus
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

I made a script for IMDB and Allociné (Fr), I started to make one for MonsieurCinema (Fr) and DVDFR (Fr), but it is a little difficult for me to make a script for a site in German :/
I may try to do it if nobody did it when I've finished with the two scripts that I started...
FFJaro

Post by FFJaro »

Hi, I'm german.
I will try to write such a script for ofdb.de . I think I know enough about this language (Pascal/Delphi).
I have wrote another script for a german movie site a few month ago.
But unfortunately I deleted it. :(

When it's finished I will release it into this forum.
suchus
Posts: 12
Joined: 2002-08-11 12:18:58
Location: Germany

Post by suchus »

@ antp and FFJaro,

greeeeeaaaat!!!
You can't believe how happy I would be to get a script for OFDb.
I really love the Ant Movie Catalog, even if all my friends using other software. However, with the script for OFDb they'll see that they picked the wrong software :D

Thank you so much!

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

Post by Bad Joker »

@ suchus

i know that amazon don't have all that fsk 18 movie stuff, but it has the best descriptions and good covers, that is all what i want ;)

all the other stuff i will get from imdb, i don't need ofdb, i think the site does not offer enough detail information about the movies and i don't like the descriptions.

don't forget from where ofdb comes from, it startet as a site for forbidden and censored movies as a user forum, and i don't need every amateur production movie, because my movies are mostly available on dvd (divx ;) ) and imdb offers me all that stuff :P

also maybe you will get the script from FFJaro ;)
Post Reply