Page 1 of 1

scripts & HTML templates

Posted: 2002-07-09 15:55:24
by Guest
these 2 hot things in the program are demanding a new section here on the site for ppl to share their scripts or templates with others

here is a nice HTML template to export your list

Code: Select all

<html><head>
<style TYPE="text/css">
  text,body,p,div,span,th,td,ul,li { FONT-SIZE: 10pt; FONT-FAMILY: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: black; background: white; }
  HR { color: black; }
  A:link { COLOR: #003399; background: white; }
  A:visited { COLOR: #003399; background: white; }
  A:hover { COLOR: #CC0000; background: white; }
  A:active { COLOR: #CC0000; background: white; }
  td.blk { color: white; background: black; border: solid; border-color: black; }
  table.blk { color: white; background: black; border: solid; border-color: black; border-width: thin; }
  table.lgt { color: black; background: white; border: solid; border-width: thin; border-color: #F5F5F5; }
  td.lgt { color: black; background: white; border: solid; border-width: thin; border-color: #F5F5F5; }
  p.title { font-size: 18pt; font-weight: bold; }
</style></head><body>
<p>Catalog created on $$DATE with <a href="http://www.buypin.com/moviecatalog.php" target="_blank">Ant Movie Catalog</a>.</p>
<table class="blk" border="1" cellspacing="0" cellpadding="5"><tr>
<td class="blk" nowrap>Number</td>
<td class="blk" nowrap>Original Title</td>
<td class="blk" nowrap>Translated Title</td>
<td class="blk" nowrap>Group Release</td>
<td class="blk" nowrap>CDs</td>
<td class="blk" nowrap>Format</td>
</tr>$$ITEM_BEGIN<tr>
<td rowspan="2" class="lgt"><strong>$$ITEM_NUMBER $$ITEM_APPRECIATION<br><a href= $$ITEM_URL target="_blank"><img src="$$ITEM_PICTUREFILENAME" width="120" height="166"> </a></strong></td>
<td class="lgt"><strong><a href= $$ITEM_URL target="_blank">$$ITEM_ORIGINALTITLE </a></strong></td>
<td class="lgt"><strong><a href= $$ITEM_URL target="_blank">$$ITEM_TRANSLATEDTITLE </a></td>
<td class="lgt">$$ITEM_PRODUCER </td>
<td class="lgt">$$ITEM_DISKS </td>
<td class="lgt">$$ITEM_TYPE </td>
</tr><tr><td colspan="6" class="lgt">$$ITEM_DESCRIPTION </td></tr><tr><td colspan="7" class="blk"></td>
</tr>$$ITEM_END</table><p><strong>Total: $$TOTALMOVIES movies</strong></p></body></html>
everyone are welcome to put their scripts or templates here :)
especialy the dude with the export to ORIGONS script :p

Posted: 2002-07-09 16:41:55
by antp
I will add a section for contributions (templates, scripts, translations).

What does this template have different from the original one ?

automatic IMDB + small pic script

Posted: 2002-07-10 08:25:03
by Guest
its not perfect but it works if you have the link to the movie on imdb already or only the imdb id only ...only in URL field
1)bring the pic. first
2)takes the first plot summary there is and puts it in the description field
3)puts the plot outline or tagline in the comments field.

if you have another link in the URL that is different than the imdb it will skip the movie and move on to the next one.

Code: Select all

// GETINFO SCRIPTING
// IMDB (US) ** Automatic ** import with small picture

(* things to work on description import:
   1) Plot summary import some summary contain
      links in the summary , need to check <> tags
      in the summary itself and delete them
   2) if there is no plot outline & no tagline to import a
      user comment if available ( 10 lines top !! usaily those users write nevels there :) ).
 *)
(***************************************************
 *  Movie importation script for:                  *
 *      IMDB (US), http://us.imdb.com              *
 *                                                 *
 *  (c) 2002 Antoine Potten    antoine@buypin.com  *
 *  Improvements made by Danny Falkov              *
 *                                                 *
 *  For use with Ant Movie Catalog 3.3.0           *
 *  www.ant.be.tf/moviecatalog ··· www.buypin.com  *
 ***************************************************)

program AutoIMDb;
var
  MovieName,id,IMDBid: 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);
//  Page.Text := Page2;
  if pos('<TITLE>IMDb', Page.Text) = 0 then
  begin
    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: string;
  LineNr: Integer;
  BeginPos, EndPos: 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);
    BeginPos := pos('<BASE HREF="', Line) + 12;
    EndPos := pos('">', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    SetField(fieldURL, Value);
  end;
  
  // Picture
  LineNr := FindLine('<IMG SRC="http://posters.imdb.com/', Page, 0);
  if LineNr < 0 then
    LineNr := FindLine('<A HREF="/ImageView?', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := pos('<IMG SRC="', Line) + 10;
    EndPos := pos('ALT="cover" ', Line);
    if (BeginPos > 10) and (EndPos > 0) then
    begin
      Value := copy(Line, BeginPos, EndPos - BeginPos - 2);
      GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
    end;
  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
    FullValue := '';
    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 FullValue <> '' then
            FullValue := FullValue + ', ';
          FullValue := FullValue + Value;
        end;
      end else
      begin
        Line := '';
      end;
    until Line = '';
    HTMLDecode(FullValue);
    SetField(fieldActors, FullValue);
  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);
      // put the plot outline in the comments field , to disable it delete the line below
    SetField(fieldComments, Value);
    BeginPos := pos('/Plot?', Line);
    EndPos := pos('"> (more)', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    GetDescriptions(Value);
    //Value := '';
    //if PickListExec('Select a description for "' + MovieName + '"', Value) then

  end;

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

  // Language
  LineNr := FindLine('Language</B>:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := pos('/">', Line) + 3;
    EndPos := pos('</A>', Line);
    if EndPos = 0 then
      EndPos := pos('</TD>', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    SetField(fieldLanguages, Value);
  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);
  if LineNr > -1 then
  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);
    SetField(fieldDescription, 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;

  // add zeros to imdb id to be a 7 chars id
procedure GetIMDBid ();
var
  URLfield : string;
  i: Integer;
begin
  URLfield := '' ;
    // if the imdb id is in another field then add\change this field here
  URLfield:=GetField(fieldURL);
  if  (length(URLfield) =  7)  then IMDBid := URLfield
    else if (length(URLfield) <  7) then
      begin
        i := Length(URLfield);
        for i := 1 to 7 - Length(URLfield) do
          IMDBid := IMDBid + '0';
        IMDBid := IMDBid + URLfield;
       end else
          // if the URL has already a link to IMDB then get the id
       //else if ( (length(URLfield) - pos('?' , URLfield)) > 7 ) then
        IMDBid := copy(URLfield , pos('?' , URLfield)+1 , Length(URLfield)+1);
end;

  //  main script
begin
 IMDBid := '';
 GetIMDBid();
 if (length(IMDBid) > 2) then
 AnalyzePage('http://us.imdb.com/Title?' + IMDBid );

end.

enjoy...now this program defenetly rules
took 1 hour to import all my 500 movies :hihi:

Posted: 2002-07-10 09:43:32
by antp
Ok thanks I will probably include it next time I update the installation package.

Posted: 2002-07-10 10:11:56
by Guest
small change ...
change this line

Code: Select all

//else if ( (length(URLfield) - pos('?' , URLfield)) > 7 ) then 
to this

Code: Select all

if ( (length(URLfield) - pos('?' , URLfield)) = 7 ) then
now it will skip movies with different URL than us.imdb...
:grinking:

Posted: 2002-07-20 15:14:06
by Guest
still waiting for that section u promissed .... ...all we want is to share the files here

Posted: 2002-07-20 16:24:35
by antp
As I said on the other topic, I'll do that now ;)