Script for FILMSTARTS.de

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
Post Reply
J
Posts: 224
Joined: 2008-02-17 17:09:26

Script for FILMSTARTS.de

Post by J »

Hi,

I wrote a small script for the german site FILMSTARTS.de.
It´s a kind of "on top" to the imdb-script, but it can be used seperately as well.

Why on-top?
Because imdb provides you with a lot of good information and much more movies.

The intention for this script was the use of the better picture and the much better description/comment (of course in german) at FILMSTARTS.de.

So, what does the script do?

1) It puts the original title to translated title and the german to original.
- I like to have the german title on the movie list.

2) Provides you with a bigger picture in better resolution

3) Puts the movie description/comment to the comments field

The script works, as far as i could test it, with the english or german title.

You only need to type in the english title, start the IMDB script as usual, then start the Filmstarts.de-script.

Code: Select all

(***************************************************

Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/

[Infos]
Authors=J
Title=Filmstarts.de
Description=Filmstarts.de
Site=ww.filmstarts.de
Language=DE
Version=1.0.0 - 18/02/2008
Requires=3.5.0
Comments=
License=IMPORTANT NOTICE:||THIS SCRIPT IS FOR PERSONAL USE ONLY ! |DO NOT REDISTRIBUTE ANY DATA WITHOUT THE PERMISSION OF THE COPYRIGHT OWNER ! RESPECT COPYRIGHTS !||The script itself is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
GetInfo=1

[Options]

***************************************************)

// FILMSTARTS.de - Script Version 1.0.0 (20080218/J)
//
// v.1.0.0 - 18/02/2008 - first public release

program FILMSTARTS;

uses
  StringUtils1;
var
  MovieName, Value: string;

procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  RealAddress, TextEnd: string;

begin
  Page := TStringList.Create;

// Get real URL with number found in search
  begin
    Page.Text := GetPage(Address);
    Value := TextBetween(Page.Text, 'http://www.filmstarts.de/produkt/', '.html');
    RealAddress := 'http://www.filmstarts.de/produkt/' + Value + '.html';
    Page.Text := GetPage(RealAddress);
  end;

// Get german title --> original title field
  Value := '';
  begin
      Value := TextBetween(Page.Text, '<h1 class="title">', '<span class="genre">');
      If Value <> '' then
      begin
        MovieName := GetField(fieldOriginalTitle);
        setField (fieldTranslatedTitle, MovieName);
        setField (fieldOriginalTitle, Value);
      end;
  end;
  
// Get big Cover //
  Value := '';
  begin
      Value := TextBetween(Page.Text, 'http://thumbs.filmstarts.de/menu/', '"');
      If Value <> '' then
      begin
        Value := 'http://thumbs.filmstarts.de/wallpaper/' + Value;
        GetPicture(Value);
      end;
  end;

// Get Movie Description/Comments --> comments field
  Value := '';
  begin

// If there´s no review then get preview
    If Pos('<div class="right bold paddingBottom">', Page.Text) > 0 then
      TextEnd := '<div class="right bold paddingBottom">'
    else
      TextEnd := '<div class="paddingBox right" style="clear:both">';
    Value := TextBetween(Page.Text, '<div class="paddingBigBox" align="justify">', TextEnd);

// *** Delete HTML-stuff for raw-Text --- start ***

// Delete starting Tabs
    Delete (Value, 1, 11);
// Delete Info Popup
    while Pos('<a class', Value) > 0 do
    Delete (Value, Pos('<a class', Value), Length(TextBetween(Value, '<a class', 'title\')) + 16);
    while Pos('</div', Value) > 0 do
    Delete (Value, Pos('</div', Value), Length(TextBetween(Value, '</div', '/a')) + 8);
// Delete Tables & Pictures
    while Pos('<table', Value) > 0 do
    Delete (Value, Pos('<table', Value), Length(TextBetween(Value, '<table', '/table')) + 13);
// Delete <...>
    while Pos('<', Value) > 0 do
    Delete (Value, Pos('<', Value), Length(TextBetween(Value, '<', '>')) + 2);
// Delete ending Tabs
    Delete (Value, Length(Value) - 10, 10);

// *** Delete HTML-stuff for raw-Text --- end ***

    setField(fieldComments, Value);
    Value := '';
  end;

end;


begin
  if AcceptLicense(1) = False then
    Exit;
  if CheckVersion(3,5,0) then
    begin
      MovieName := GetField(fieldOriginalTitle);
      if MovieName = '' then
        MovieName := GetField(fieldTranslatedTitle);
      if Input('Filmstarts.de Import', 'Enter the title of the movie:', MovieName) then
      begin
// FILMSTARTS.de handles apostrophes with different & changing characters in search function and title-URL,
// but works mostly with auto-cutting apostrophe and rest of word. (e.g. I´ve --> I).
// -- If that wouldn´t work, type in title without apo-word (e.g. "not there" instead of "i´m not there")
        MovieName := StringReplace (MovieName, #39, '´');
        if Pos('´', MovieName) > 0 then
        Delete (MovieName, Pos('´', MovieName), Length(TextBetween(Moviename, '´', ' ')) + 1);
// Use FILMSTARTS.de internal search function to get working title-URL
        AnalyzePage('http://www.filmstarts.de/suche.html?anfrage='+UrlEncode(MovieName));
      end;
    end
  else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
end.


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

Post by antp »

Thanks.
Maybe it could be useful to mention in the license that you have to run the IMDB script first?
J
Posts: 224
Joined: 2008-02-17 17:09:26

Post by J »

Sure I can do, but it´s not necessarily needed to run imdb or any other script before.

It´s only because i actually was too lazy to write the script with complete data import. Maybe I will do this in next version.
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

J wrote:but it´s not necessarily needed to run imdb or any other script before.
ok then ;)
J
Posts: 224
Joined: 2008-02-17 17:09:26

Post by J »

Just for my information, is there a way to call one script from another?
bad4u
Posts: 1148
Joined: 2006-12-11 22:54:46

Re: Script for FILMSTARTS.de

Post by bad4u »

J wrote:1) It puts the original title to translated title and the german to original.
- I like to have the german title on the movie list.
Just a note: This could be done on preferences without any changes to the fields. Tools -> Preferences -> Book List -> Title formatting -> Title to display ;)
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

J wrote:Just for my information, is there a way to call one script from another?
If the script is put in functions ready for that maybe, but I think that the content between the "begin/end." part of the script (from where the script starts) will interfer.
For an example on how to use other files, see scripts using stringutils1.pas
J
Posts: 224
Joined: 2008-02-17 17:09:26

Post by J »

Oooops, yes a look into the preferences can be helpfull sometimes :ha:
J
Posts: 224
Joined: 2008-02-17 17:09:26

Version 1.1

Post by J »

Hi,

this is the second version of my script FILMSTARTS.de.

It´s much of an improvement to the first one.
I added a lot of new things to make it more comfortable and complete.

* Import of nearly all usefull data, can be now used as full standalone script
* Added several options for import
* Included a selection box for movies and comments list
* Better exception handling
* Better parsing of description/comment text

Hope it´s of use for somebody.
J.

Code: Select all

(***************************************************

Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/

[Infos]
Authors=J
Title=Filmstarts.de
Description=Script for Filmstarts.de with options
Site=ww.filmstarts.de
Language=DE
Version=1.1.0 - 23/02/2008
Requires=3.5.0
Comments=
License=IMPORTANT NOTICE:||THIS SCRIPT IS FOR PERSONAL USE ONLY ! |DO NOT REDISTRIBUTE ANY DATA WITHOUT THE PERMISSION OF THE COPYRIGHT OWNER ! RESPECT COPYRIGHTS !||The script itself is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
GetInfo=1

[Options]
Title=4|4|0=No import|1=German --> original|2=German --> translated|3=German --> original & original --> translated|4=German --> translated & original --> original
Review=2|3|0=No review or comments import|1=Review --> description|2=Review --> comments|3=Review --> description & guest comment --> comments
Actors=2|2|0=No import|1=Only actor names, separated by commas|2=Actors names with character names between parenthesis separated by commas
Rating=0|1|0=No import|1=Import FILMSTARTS.de rating
Picture=0|2|0=No import|1=Import small poster|2=Import big poster
Category=0|1|0=No import|1=Oh yes, import me pls!

***************************************************)

// FILMSTARTS.de - Script Version 1.1.0 (20080223/J)
//
// v.1.1.0 - 23/02/2008 - second public release

program FILMSTARTS;

uses
  StringUtils1;
var
  MovieName, Value, Value1: string;

procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  RealAddress, TextEnd, TextBody: string;
  Counter: Integer;
  
begin
  Page := TStringList.Create;
  Value := '';
  Value1 := '';
  TextBody := '';
  Counter := 0;
  
// ***** Find movie(s)
  begin
    Page.Text := GetPage(Address);
    PickTreeClear;
// Looking for search result(s)
    If Pos('Leider keine Ergebnisse', Page.Text) = 0 then
      begin
        TextBody := TextBetween(Page.Text, '<div class="title">', '</table>');
        Value := TextBefore(TextBody, '<', '');
// More than one result?
        while Value <> '' do
        begin
// Name & real movie URL
          RealAddress := 'http' + TextBetween(TextBody, 'http', 'html') + 'html';
          PickTreeAdd(Value, RealAddress);
          Counter := Counter + 1;
          Delete (TextBody, 1 , Pos('<div class="title">', TextBody) + 11);
          Value := TextBetween(TextBody, 'title">', '<');
        end;
// Choose movie from list if more than one
        If counter > 1 then PickTreeExec(RealAddress);
        Page.Text := GetPage(RealAddress);
      end
    else
// No movie found
      begin
        ShowMessage('Leider keinen Film zu diesem Namen gefunden.');
        Exit;
      end;
  end;

// ***** Title
  Value := '';
  Value1 := '';
  begin
// German title
      Value := TextBetween(Page.Text, '<h1 class="title">', '<span class="genre">');
// Original title <> German title?
      if Pos('Originaltitel', Page.Text) > 0 then
        begin
          Value1 := TextBetween(Page.Text, 'Originaltitel:</td>', '</td>');
          Delete (Value1, 1, 32);
        end
      else
        Value1 := Value;
        case GetOption('Title') of
          1:
          setField (fieldOriginalTitle, Value);
          2:
          setField (fieldTranslatedTitle, Value);
          3:
          begin
          setField (fieldOriginalTitle, Value);
          setField (fieldTranslatedTitle, Value1);
          end;
          4:
          begin
          setField (fieldTranslatedTitle, Value);
          setField (fieldOriginalTitle, Value1);
          end;
        end;
  end;

// ***** Picture
  Value := '';
  begin
      Value := TextBetween(Page.Text, 'http://thumbs.filmstarts.de/menu/', '"');
      If Value <> '' then
        begin
          case GetOption('Picture') of
            1:
            GetPicture('http://thumbs.filmstarts.de/menu/' + Value);
            2:
            begin
            Value := 'http://thumbs.filmstarts.de/wallpaper/' + Value;
            GetPicture(Value);
            end;
          end;
        end;
  end;

// ***** Rating
  Value := '';
  if GetOption('Rating') = 1 then
    begin
      Value := TextBetween(Page.Text, 'Wertung: ', ' Punkte');
      setField(fieldRating, Value);
    end;

// ***** Year & Country
  Value := '';
  begin
      Value := TextBetween(Page.Text, 'year_country">      ', ' ');
      setField(fieldCountry, Value);
      Value := TextBetween(Page.Text, 'year_country">', '</span>');
      Delete (Value, 1, Length(Value) - 4);
      setField(fieldYear, Value);
  end;

// ***** Lenght
  Value := '';
  begin
      Value := TextBetween(Page.Text, 'Laufzeit:', ' Minuten');
      Delete (Value, 1, 37);
      setField(fieldLength, Value);
  end;

// ***** Category
  Value := '';
  if GetOption('Category') = 1 then
    begin
      Value := TextBetween(Page.Text, 'genre', ')</span');
      Delete (Value, 1, 15);
      setField(fieldCategory, Value);
    end;

// ***** URL
  setField(fieldURL, RealAddress);

// ***** Actors & director
  Value := '';
  Value1 := '';
  Counter := 0;
// Get director
  begin
    Value := TextBetween(Page.Text, 'Regie', '</a>');
    Value := TextAfter(Value, 'class="bold"');
    Delete (Value, 1, 19);
    Delete (Value, length(Value) - 16, 17);
    setfield (fieldDirector, Value);
  end;
// Get Actors page
  if Pos('Weitere Besetzung', Page.Text) > 0 then
    begin
      Address := StringReplace(RealAddress, 'produkt', 'kritiken');
      Address := StringReplace(Address, '.html', '/besetzung.html');
      TextBody := TextBetween(GetPage(Address), 'Schauspieler', '</table>');
// Get actors
      begin
        Counter := GetOption('Actors');
        case Counter of
          1,2:
          begin
            while Pos('class="bold"', TextBody) > 0 do
              begin
              Value := TextBetween(TextBody, 'class="bold"', '</a>');
// Delete blank chars before & after name
              Delete (Value, 1, 18);
              Delete (Value, length(Value) - 15, 16);
// Role (if exists)
              if (Counter = 2) and (Pos('class="paddingLeft"', TextBody) > 0) then
                begin
                  Value1 := Value1 + Value + ' ';
                  Value := TextBetween(TextBody, 'paddingLeft', '</div>');
                  Delete (Value, 1, 21);
                  Delete (Value, length(Value) - 12, 13);
                  Value1 := Value1 + '(' + Value + '), ';
                end
              else Value1 := Value1 + Value + ', ';
              TextBody := RemainingText;
              end;
// Delete last comma
            Delete (Value1, length(Value1) - 1, 1);
            setField (fieldActors , Value1);
          end;
        end;
      end;
    end;
    


// ***** Description (review/preview) parsing
  Value := '';
  Value1 :='';
  begin
// If there´s no review then get preview
    If Pos('<div class="right bold paddingBottom">', Page.Text) > 0 then
      TextEnd := '<div class="right bold paddingBottom">'
    else
      TextEnd := '<div class="paddingBox right" style="clear:both">';
    Value := TextBetween(Page.Text, '<div class="paddingBigBox" align="justify">', TextEnd);
// Delete HTML stuff to get raw text --- start ********
// Delete starting Tabs
    Delete (Value, 1, 11);
// Delete Info Popup
    while Pos('<a class', Value) > 0 do
    Delete (Value, Pos('<a class', Value), Length(TextBetween(Value, '<a class', 'title\')) + 16);
    while Pos('</div', Value) > 0 do
    Delete (Value, Pos('</div', Value), Length(TextBetween(Value, '</div', '/a')) + 8);
// Delete Tables & Pictures
    while Pos('<table', Value) > 0 do
    Delete (Value, Pos('<table', Value), Length(TextBetween(Value, '<table', '/table')) + 13);
// Delete <...>
    while Pos('<', Value) > 0 do
    Delete (Value, Pos('<', Value), Length(TextBetween(Value, '<', '>')) + 2);
// Delete ending Tabs
    Delete (Value, Length(Value) - 10, 10);
// Change old Tags
    Value := StringReplace(Value, ''', '´');
    Value := StringReplace(Value, '"', '"');
// Delete HTML stuff to get raw text --- end *******

// ***** Comments & description
    case GetOption('Review') of
      1:
        setField (fieldDescription, Value);
      2:
        setField (fieldComments, Value);
      3:
        begin
          setField (fieldDescription, Value);
// Get guest comments page
          Address := StringReplace(RealAddress, 'produkt', 'kommentare');
          Address := StringReplace(Address, '.html', '/');
          TextBody := GetPage(Address);
// Comment exists?
          If Pos('kommentar_', TextBody) > 0 then
            begin
              Value := TextBetween(TextBody, 'cbox_', '</div>');
// More than one comment?
              while Value <> '' do
                begin
                  TextBody := RemainingText;
// Delete starting characters
                  Delete (Value, 1, 17);
// Delete ending characters
                  Delete (Value, Length(Value) - 5, 5);
// Change old Tags
                  Value := StringReplace(Value, '<br />', '');
                  Value := StringReplace(Value, '"', '"');
// Add comment to selection list
                  PickListAdd(Value);
                  Value := TextBetween(TextBody, 'cbox_', '</div>');
                end;
// Choose comment from list
              PickListExec('Wählen sie einen Kommentar für "' + GetField(fieldOriginalTitle) + '"', Value1)
              SetField (fieldComments, Value1);
            end;
          end;
    end;
  end;
end;



// ***** Start of program
begin
  if AcceptLicense(1) = False then
    Exit;
  if CheckVersion(3,5,0) then
    begin
      MovieName := GetField(fieldOriginalTitle);
      if MovieName = '' then
        MovieName := GetField(fieldTranslatedTitle);
      if Input('Filmstarts.de Import', 'Enter the title of the movie:', MovieName) then
      begin
// FILMSTARTS.de handles apostrophes with different & changing characters in search function and title-URL,
// but works mostly with auto-cutting apostrophe and rest of word. (e.g. I´ve --> I).
// -- If that wouldn´t work, type in title without apo-word (e.g. "not there" instead of "i´m not there")
        MovieName := StringReplace (MovieName, #39, '´');
        if Pos('´', MovieName) > 0 then
        Delete (MovieName, Pos('´', MovieName), Length(TextBetween(Moviename, '´', ' ')) + 1);
// Use FILMSTARTS.de internal search function to get working title-URL
        AnalyzePage('http://www.filmstarts.de/suche.html?anfrage='+UrlEncode(MovieName));
      end;
    end
  else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
end.
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks
aii
Posts: 3
Joined: 2008-03-14 23:29:42

Post by aii »

Sadly i get a syntax error in line 223.
bad4u
Posts: 1148
Joined: 2006-12-11 22:54:46

Post by bad4u »

You are right. There is an little error in handling the ' in the script.

Change

Code: Select all

// Change old Tags
    Value := StringReplace(Value, ''', '´');
to

Code: Select all

// Change old Tags
    Value := StringReplace(Value, '''', '´');
and it will work again.
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

in
Value := StringReplace(Value, ''', '´');
put 4 ' instead of 3 :
Value := StringReplace(Value, '''', '´');

edit : bad4u was faster :o
Last edited by antp on 2008-03-14 23:50:03, edited 1 time in total.
aii
Posts: 3
Joined: 2008-03-14 23:29:42

Post by aii »

Thanks alot. Both of you
J
Posts: 224
Joined: 2008-02-17 17:09:26

Post by J »

Hm, seems to be a copy&paste error.

Anyway, thanks for correcting.
J
Posts: 224
Joined: 2008-02-17 17:09:26

Update to v1.2

Post by J »

Because of some changes at filmstarts you´ll need this new version of the script.

Enjoy.

Code: Select all

(***************************************************

Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/

[Infos]
Authors=J
Title=Filmstarts.de
Description=Script for Filmstarts.de with options
Site=ww.filmstarts.de
Language=DE
Version=1.2 - 25/05/2008
Requires=3.5.0
Comments=V 1.0.0|Only description & big poster import||V 1.1.0|Import of all data with options||V1.1.1|Added selection for IMDB at rating option|Added IMDB-Rating fom Filmstarts.de if available|Small Code changes - no change of functionality||V1.2|Adaption to several site changes|No new functionality
License=IMPORTANT NOTICE:||THIS SCRIPT IS FOR PERSONAL USE ONLY ! |DO NOT REDISTRIBUTE ANY DATA WITHOUT THE PERMISSION OF THE COPYRIGHT OWNER ! RESPECT COPYRIGHTS !||The script itself is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
GetInfo=1

[Options]
Title=3|3|0=No import|1=German --> original|2=German --> translated|3=German --> original & original --> translated|4=German --> translated & original --> original
Review=3|3|0=No review or comments import|1=Review --> description|2=Review --> comments|3=Review --> description & guest comment --> comments
Actors=2|2|0=No import|1=Only actor names, separated by commas|2=Actors names with character names between parenthesis separated by commas
Rating=2|2|0=No import|1=FILMSTARTS rating|2=IMDB rating
Picture=2|2|0=No import|1=Small poster|2=Big poster
Category=1|1|0=No import|1=Oh yes, import me pls!

***************************************************)

// FILMSTARTS.de - Script Version 1.2 (20080525/J)
//
// v.1.2 - 25/05/2008 - third public release

program FILMSTARTS;

uses
  StringUtils1;
var
  MovieName, Value, Value1: string;

procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  RealAddress, TextEnd, TextBody: string;
  Counter: Integer;
  
begin
  Page := TStringList.Create;
  Value := '';
  Value1 := '';
  TextBody := '';
  Counter := 0;
  
// ***** Find movie(s)
  begin
    Page.Text := GetPage(Address);
    PickTreeClear;
    Value := Page.Text;


// Looking for search result(s)
    If Pos('leider keine Ergebnisse', Page.Text) = 0 then
      begin
        TextBody := TextBetween(Page.Text, 'suggestBox', 'end_float');
        Value := TextBetween(TextBody, 'class="t">', '</span>');
// More than one result?
        while Value <> '' do
        begin
// Name & real movie URL
          RealAddress := 'http://www.filmstarts.de/kritiken/' + TextBetween(TextBody, 'kritiken/', 'html') + 'html';
          PickTreeAdd(Value, RealAddress);
          Counter := Counter + 1;
          Delete (TextBody, 1 , Pos('</li>', TextBody));
          Value := TextBetween(TextBody, 'class="t">', '</span>');
        end;
// Choose movie from list if more than one
        If counter > 1 then PickTreeExec(RealAddress);
        Page.Text := GetPage(RealAddress);
      end
    else
// No movie found
      begin
        ShowMessage('Leider keinen Film zu diesem Namen gefunden.');
        Exit;
      end;
  end;

// ***** Title
  Value := '';
  Value1 := '';
  begin
// German title
      Value := TextBetween(Page.Text, 'left:10px;">', '</div>');
// Original title <> German title?
      if Pos('Originaltitel', Page.Text) > 0 then
        begin
          Value1 := TextBetween(Page.Text, 'Originaltitel: ', '</div>');
        end
      else
        Value1 := Value;
        case GetOption('Title') of
          1:
          setField (fieldOriginalTitle, Value);
          2:
          setField (fieldTranslatedTitle, Value);
          3:
          begin
          setField (fieldOriginalTitle, Value);
          setField (fieldTranslatedTitle, Value1);
          end;
          4:
          begin
          setField (fieldTranslatedTitle, Value);
          setField (fieldOriginalTitle, Value1);
          end;
        end;
  end;

// ***** Picture
  Value := '';
  begin
      Value := TextBetween(Page.Text, 'http://thumbs.filmstarts.de/menu/', '"');
      If Value <> '' then
        begin
          case GetOption('Picture') of
            1:
            GetPicture('http://thumbs.filmstarts.de/menu/' + Value);
            2:
            GetPicture('http://thumbs.filmstarts.de/wallpaper/' + Value);
          end;
        end;
  end;

// ***** Rating
  Value := '';
  case GetOption('Rating') of
    1:
      setField(fieldRating, TextBetween(Page.Text, 'alt="Wertung: ', ' /'));
    2:
// IMDB rating (if available on FILMSTARTS.de)
      begin
        if pos('ImDB.com', Page.Text) >0 then
          begin
            Textbody := TextBetween(Page.Text, 'ImDB.com', '/10');
            Value := TextAfter (Textbody, '"r">');
            setField(fieldRating, Value);
          end;
      end;
  end;

// ***** Year & Country
  Value := '';
  Textbody := '';
  begin
      Textbody := TextBetween(Page.Text, '/kritiken/genre/', ' </div>');
      Value := TextBetween(Textbody, '"weak">', ' ');
      Delete (Value, 1, 2);
      setField(fieldCountry, Value);
      Delete (Textbody, 1, Length(Textbody) - 4);
      setField(fieldYear, Textbody);
  end;

// ***** Lenght
  Value := '';
  begin
      Value := TextBetween(Page.Text, 'Laufzeit:', ' Minuten');
      Delete (Value, 1, 30);
      setField(fieldLength, Value);
  end;

// ***** Category
  Value := '';
  if GetOption('Category') = 1 then
    begin
      Value := TextBetween(Page.Text, 'class="standard">', '</a');
      setField(fieldCategory, Value);
    end;

// ***** URL *****
  setField(fieldURL, RealAddress);

// ***** Actors & director
  Value := '';
  Value1 := '';
  Counter := 0;
  TextBody := '';
// Get director
  begin
    TextBody := TextBetween(Page.Text, '>Regie<', 'end_float');
    Value := TextBetween(TextBody, 'name">', '</');
    setfield (fieldDirector, Value);
  end;
// Get Actors page
  if Pos('Schauspieler</span>', Page.Text) > 0 then
    begin
// Sometimes address of castcrew-page is of different structure than movie-page (e.g. "the bank job / bank job")
//      Address := StringReplace(RealAddress, '.html', '/castcrew.html');
      Address := 'http://filmstarts.de/kritiken/' + TextBefore(Page.Text, 'castcrew.html', 'kritiken/') + 'castcrew.html';
      TextBody := TextBetween(GetPage(Address), 'Schauspieler</li>', '</ul>');
// Get actors
      begin
        Counter := GetOption('Actors');
        case Counter of
          1,2:
          begin
            while Pos('"name"', TextBody) > 0 do
              begin
              Value := TextBetween(TextBody, '"name">', '</');
// Role (if exists)
              if (Counter = 2) and (Pos('>als ', TextBody) > 0) then
                begin
                  Value1 := Value1 + Value +  ' (' + TextBetween(TextBody, '>als ', '</span>') + '), ';
                end
              else Value1 := Value1 + Value + ', ';
              TextBody := RemainingText;
              end;
// Delete last comma
            Delete (Value1, length(Value1) - 1, 1);
            setField (fieldActors , Value1);
          end;
        end;
      end;
    end;
    
// ***** Description (review/preview) parsing
  Value := '';
  Value1 :='';
  begin
// If there´s no review then get preview
    If Pos('<p class="author">', Page.Text) > 0 then
      TextEnd := '<p class="author"'
    else
      TextEnd := '<div class="weak"><b>Hinweis:';
    Value := TextBetween(Page.Text, 'critic topBorder">', TextEnd);
// Delete HTML stuff to get raw text --- start ********
// Marker for deletion of "Bildgalerie"
    Value := StringReplace(Value, '"line-height:15px;">', '/a>' + #13#10);
    Value := StringReplace(Value, '/a>' + #13#10, '/a>');
// Delete additional info
    while Pos('<a class', Value) > 0 do
    Delete (Value, Pos('<a class', Value), Length(TextBetween(Value, '<a class', 'title\')) + 16);
    while Pos('</div', Value) > 0 do
    Delete (Value, Pos('</div', Value), Length(TextBetween(Value, '</div', '/a>'))+ 8);
// Change </br> to CR
    Value := StringReplace(Value, '<br />', #13#10);
// Delete <...>
    while Pos('<', Value) > 0 do
    Delete (Value, Pos('<', Value), Length(TextBetween(Value, '<', '>')) + 2);
// Delete beginning characters
    Delete (Value, 1, 2);
// Change old Tags
    Value := StringReplace(Value, ''', '´');
    Value := StringReplace(Value, '"', '"');
// Delete HTML stuff to get raw text --- end *******

// ***** Comments & description
    case GetOption('Review') of
      1:
        setField (fieldDescription, Value);
      2:
        setField (fieldComments, Value);
      3:
        begin
          setField (fieldDescription, Value);
// Comment exists?
          If Pos('Alle Gastkritiken', Page.Text) > 0 then
            begin
// Get guest comments page & comment
              Address := StringReplace(RealAddress, '.html', '/Gastkritiken.html');
              TextBody := GetPage(Address);
              Value := TextBetween(TextBody, '</span></span></div></div>', '</div>');
// More than one comment?
              while Value <> '' do
                begin
                  TextBody := RemainingText;
// Delete starting characters
                  Delete (Value, 1, 20);
// Delete ending characters
//                  Delete (Value, Length(Value) - 5, 5);
// Change old Tags
                  Value := StringReplace(Value, '<br />', #13#10);
                  Value := StringReplace(Value, ''', '´');
                  Value := StringReplace(Value, '"', '"');
// Add comment to selection list
                  PickListAdd(Value);
                  Value := TextBetween(TextBody, '</span></span></div></div>', '</div>');
                end;
// Choose comment from list
              PickListExec('Wählen sie einen Kommentar für "' + GetField(fieldOriginalTitle) + '"', Value1)
              SetField (fieldComments, Value1);
            end;
        end;
    end;
  end;
end;


// ***** Start of program
begin
  if AcceptLicense(1) = False then
    Exit;
  if CheckVersion(3,5,0) then
    begin
      MovieName := GetField(fieldOriginalTitle);
      if MovieName = '' then
        MovieName := GetField(fieldTranslatedTitle);
      if Input('Filmstarts.de Import', 'Enter the title of the movie:', MovieName) then
      begin
// FILMSTARTS.de handles apostrophes with different & changing characters in search function and title-URL,
// but works mostly with auto-cutting apostrophe and rest of word. (e.g. I´ve --> I).
// -- If that wouldn´t work, type in title without apo-word (e.g. "not there" instead of "i´m not there")
        MovieName := StringReplace (MovieName, #39, '´');
        if Pos('´', MovieName) > 0 then
        Delete (MovieName, Pos('´', MovieName), Length(TextBetween(Moviename, '´', ' ')) + 1);
// Use FILMSTARTS.de internal search function to get working title-URL
        AnalyzePage('http://www.filmstarts.de/finde.html?anfrage='+UrlEncode(MovieName));
      end;
    end
  else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
end.
J
Posts: 224
Joined: 2008-02-17 17:09:26

New Release

Post by J »

After a total redesign and VERY long time of beta testing, the development of FILMSTARTS.de seems now to be stable for a while and so I decided to write a complete new script for it. Because of some page design changes, the script functionality also has changed slightly. Take a look in the options.

It´s roughly tested but should work for most of the movies.

Have fun.

Code: Select all

(***************************************************

Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/

[Infos]
Authors=J
Title=Filmstarts.de
Description=Script for Filmstarts.de with options
Site=www.filmstarts.de
Language=DE
Version=2.0.1 - 11/01/2011
Requires=3.5.0
Comments=V 1.0.0|Only description & big poster import||V 1.1.0|Import of all data with options||V1.1.1|Added selection for IMDB at rating option|Added IMDB-Rating fom Filmstarts.de if available|Small Code changes - no change of functionality||V1.2|Adaption to several site changes|No new functionality||V2.0.1|Totally new rewritten script after filmstarts.de redesign|Some different options.
License=IMPORTANT NOTICE:||THIS SCRIPT IS FOR PERSONAL USE ONLY ! |DO NOT REDISTRIBUTE ANY DATA WITHOUT THE PERMISSION OF THE COPYRIGHT OWNER ! RESPECT COPYRIGHTS !||The script itself is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
GetInfo=1

[Options]
Title=3|3|0=No import|1=German --> original|2=German --> translated|3=German --> original & Original --> translated|4=German --> translated & Original --> original
Review=4|4|0=No review or comments import|1=Review --> description|2=Review --> comments|3=Review --> description & guest comment --> comments|4=Summary --> description & Reviev --> comments
Actors=2|2|0=No import|1=Only actor names, separated by commas|2=Actors names with character names between parenthesis separated by commas
Rating=1|1|0=No import|1=FILMSTARTS rating|2=press average
Picture=2|2|0=No import|1=Small poster|2=Big poster
Category=1|1|0=No import|1=Oh yes, import me pls!

***************************************************)

// FILMSTARTS.de - Script Version 2.0 (20110111/J)
//
// v2.0.1 - 11/01/2011 - Totally new version after page redesign

program FILMSTARTS;

uses
  StringUtils1;
var
  MovieName: string;

procedure AnalyzePage(Address: string);
var
  PageText, RealAddress, TextBody, Value, Value1: string;
  Counter: Integer;
  
begin
  Value := '';
  Value1 := '';
  TextBody := '';
  Counter := 0;

// ***** Find movie(s)
  begin
    PageText := GetPage(Address);
    PageText := UTF8Decode(PageText);
    PickTreeClear;
// Looking for search result(s)
  If Pos('Filme</h2>', PageText) = 0 then
// No movie found
    begin
      ShowMessage('Leider keinen Film zu diesem Namen gefunden.');
      Exit;
    end;
// Get movie list
    begin
        TextBody := TextBetween(PageText, 'totalwidth">', '/table');
        Value := FullTrim(TextBetween(TextBody, 'html' + #39 + '>', '</a>'));
        Value := StringReplace(value, '<b>', '');
        Value := StringReplace(value, '</b>', '');
        Value := Value + ' (' + FullTrim(TextBetween(TextBody, 'fs11">', '<br')) + ')';
        RealAddress := 'http://www.filmstarts.de/kritiken/' + TextBetween(TextBody, 'kritiken/', 'html') + 'html';
        PickTreeAdd(Value, RealAddress);
        Counter := Counter + 1;
// More than one result?
        while Pos('totalwidth', TextBody) <> 0 do
        begin
// Name & real movie URL
          Delete (TextBody, 1 , Pos('totalwidth', TextBody));
          Value := FullTrim(TextBetween(TextBody, 'html' + #39 + '>', '</a>'));
          Value := StringReplace(value, '<b>', '');
          Value := StringReplace(value, '</b>', '');
          Value := Value + ' (' + FullTrim(TextBetween(TextBody, 'fs11">', '<br')) + ')';
          RealAddress := 'http://www.filmstarts.de/kritiken/' + TextBetween(TextBody, 'kritiken/', 'html') + 'html';
          PickTreeAdd(Value, RealAddress);
          Counter := Counter + 1;
        end;
// Choose movie from list if more than one
        If counter > 1 then PickTreeExec(RealAddress);
// Load movie-page
        PageText := GetPage(RealAddress);
        PageText := UTF8Decode(PageText);
      end
    end;

// ***** Title
  begin
// German title
      Value := FullTrim(TextBetween(PageText, '<h1 property="v:name">', '</h1>'));
// Original title <> German title?
      if Pos('Originaltitel', PageText) > 0 then
        begin
          Value1 := TextBetween(PageText, 'class="purehtml"><em>', '</em>');
        end
      else
        Value1 := Value;
        case GetOption('Title') of
          1:
          setField (fieldOriginalTitle, Value);
          2:
          setField (fieldTranslatedTitle, Value);
          3:
          begin
          setField (fieldOriginalTitle, Value);
          setField (fieldTranslatedTitle, Value1);
          end;
          4:
          begin
          setField (fieldTranslatedTitle, Value);
          setField (fieldOriginalTitle, Value1);
          end;
        end;
  end;

// ***** Picture
  begin
      Value := TextBetween(PageText, 'r_160_214/b_1_cfd7e1/medias/nmedia/', #39);
      If Value <> '' then
        begin
          case GetOption('Picture') of
            1:
            GetPicture('http://bilder.filmstarts.de/r_160_214/b_1_cfd7e1/medias/nmedia/' + Value);
            2:
            begin
            GetPicture('http://bilder.filmstarts.de/r_760_x/medias/nmedia/' + Value);
            end;
          end;
        end;
  end;

// ***** Rating
  case GetOption('Rating') of
    1:
      begin
        Value := FloatToStr(StrToFloat(TextBetween(PageText, 'stareval n', ' '))/5);
        setField (fieldRating, Value);
      end;
    2:
      begin
        if pos('Presseschnitt', PageText) >0 then
          begin
            Textbody := TextBetween(PageText, 'Presseschnitt', ')');
            Value := TextAfter(Textbody, '(');
            Value := StringReplace(Value, ',', '.');
            Value := FloatToStr(StrToFloat(Value)*2);
            setField(fieldRating, Value);
          end;
      end;
  end;

// ***** Countries
  begin
      Textbody := TextBetween(PageText, 'Produktionsland', 'Genre');
      Value := TextBetween(Textbody, '">', '<');
      Delete (Textbody, 1, Pos('</', Textbody));
      while Pos('">', Textbody) > 0 do
      begin
        Value := Value + ', ' + TextBetween(Textbody, '">', '<');
        Delete (Textbody, 1, Pos('</', Textbody));
      end;
      Value := StringReplace(Value, 'Vereinigte Staaten', 'USA');
      setField(fieldCountry, Value);
  end;

// ***** Categories
  If GetOption('Category') =1 Then
    begin
      Textbody := TextBetween(PageText, 'Genre', '<br />');
      Value := TextBetween(Textbody, '">', '<');
      Delete (Textbody, 1, Pos('</', Textbody));
      while Pos('">', Textbody) > 0 do
      begin
        Value := Value + ', ' + TextBetween(Textbody, '">', '<');
        Delete (Textbody, 1, Pos('</', Textbody));
      end;
      setField(fieldCategory, Value);
    end;

// ***** Lenght
  Value := FullTrim(TextBetween(PageText, 'Laufzeit:', ' Minuten'));
  setField(fieldLength, Value);

// ***** Year
  Textbody := TextBetween(PageText, 'Produktionsjahr', '/span');
  Value := TextBetween(Textbody, '">', '<');
  setField(fieldYear, Value);

// ***** URL *****
  setField(fieldURL, RealAddress);

// ***** Description / Summary & Comments
  begin
    Value1 := TextBetween(PageText, 'summary">', '</span>');
    HTMLRemoveTags(Value1);
    if Pos('kritik.html', PageText) <> 0 then
      begin
        Address := StringReplace(RealAddress, '.html', '/kritik.html');
// Load description-page
        PageText := GetPage(Address);
        Value := TextBetween(PageText, 'purehtml">', '</p>');
        HTMLRemoveTags(Value);
        Value := UTF8Decode(Value);
// Deletes old formatting CR
        while Pos(#13#10 + #13#10 + #13#10, Value) > 0 do
        Value := StringReplace(Value, #13#10+#13#10+#13#10, #13#10);
        case GetOption('Review') of
          1:
            setField (fieldDescription, Value);
          2:
            setField (fieldComments, Value);
          3:
            begin
              setField (fieldDescription, Value);
              If Pos('gastkritiken.html', PageText) > 0 then
              begin
                Address := StringReplace(RealAddress, '.html', '/gastkritiken.html');
// Load user-comments-page
                PageText := GetPage(Address);
                TextBody := TextBetween(PageText, 'Kritik:', 'morezone');
                TextBody := UTF8Decode(TextBody);
                while Pos('/mainzone', TextBody) <> 0 do
                  begin
                    Value := FullTrim(TextBetween(TextBody, '</span>', '</p>'));
// Add comment to selection list
                    PickListAdd(Value);
                    TextBody := TextAfter (TextBody, 'Kritik:');
                  end;
// Choose comment from list
                PickListExec('Wählen sie einen Kommentar für "' + GetField(fieldOriginalTitle) + '"', Value1)
                while Pos(#13#10 + #13#10 + #13#10, Value1) > 0 do
                Value1 := StringReplace(Value1, #13#10+#13#10+#13#10, #13#10);
                SetField (fieldComments, Value1);
              end;
            end;
          4:
            begin
              setField (fieldComments, Value);
              setField (fieldDescription, Value1);
            end;
        end;
      end
    else setField (fieldDescription, Value1);
  end;

// ***** Director(s)
  begin
    Address := StringReplace(RealAddress, '.html', '/castcrew.html');
// Load actors-page
    PageText := GetPage(Address);
    PageText := UTF8Decode(PageText);
    TextBody := TextBetween(PageText, '<h3>', '<h2>');
    Value := TextBetween(TextBody, 'E48">', '</span>');
    Delete (Textbody, 1, Pos('</h3>', Textbody));
    while Pos('<h3>', Textbody) > 0 do
      begin
        Delete (Textbody, 1, Pos('<h3>', Textbody));
        Value := Value + ', ' + TextBetween(Textbody, 'E48">', '</span>');
        Delete (Textbody, 1, Pos('</h3>', Textbody));
      end;
    setfield (fieldDirector, Value);
  end;

// ***** Actors & voices
  Value := '';
  Counter := GetOption('Actors');
  If counter > 0 then
  begin
// Actors
    If Pos('<h2>Schauspieler', PageText) > 0 then
    begin
      TextBody := TextBetween(PageText, '<h2>Schauspieler', '<h2>');
      case Counter of
      1,2:
        begin
         while Pos('<h3>', TextBody) > 0 do
           begin
             Value1 := TextBetween(TextBody, '<h3>', '"spacer"');
              if (Counter = 2) then Value := Value + TextBetween(Value1, '">', '</') + ' (' + FullTrim(TextBetween(Value1, 'Rolle: ', '</p>')) + '), '
              else Value := Value + TextBetween(Value1, '">', '</') + ', ';
              Delete (Textbody, 1, Pos('</h3>', TextBody));
            end;
// Delete last comma (if no voices)
          If Pos('<h2>Synchronstimmen', PageText) = 0 then Delete (Value, length(Value) - 1, 1);
        end;
      end;
    end;
// Voices
    If Pos('<h2>Synchronstimmen', PageText) > 0 then
    begin
      TextBody := TextBetween(PageText, '<h2>Synchronstimmen', '<h2>');
      case Counter of
      1,2:
        begin
          while Pos('<h3>', TextBody) > 0 do
            begin
              Value1 := TextBetween(TextBody, '<h3>', '"spacer"');
              if (Counter = 2) then Value := Value + TextBetween(Value1, '">', '</') + ' (' + FullTrim(TextBetween(Value1, 'Rolle: ', '</p>')) + '), '
              else Value := Value + TextBetween(Value1, '">', '</') + ', ';
              Delete (Textbody, 1, Pos('</h3>', TextBody));
            end;
// Delete last comma
          Delete (Value, length(Value) - 1, 1);
       end;
     end;
    end;
    setField (fieldActors , Value);
  end;

end; // End of procedure AnalyzePage

// ***** Start of program
begin
  if AcceptLicense(1) = False then
    Exit;
  if CheckVersion(3,5,0) then
    begin
      MovieName := GetField(fieldOriginalTitle);
      if MovieName = '' then
        MovieName := GetField(fieldTranslatedTitle);
      if Input('Filmstarts.de Import', 'Enter the title of the movie:', MovieName) then
      begin
// FILMSTARTS.de handles apostrophes with different & changing characters in search function and title-URL,
// but works mostly with auto-cutting apostrophe and rest of word. (e.g. I´ve --> I).
// -- If that wouldn´t work, type in title without apo-word (e.g. "not there" instead of "i´m not there")
        MovieName := StringReplace (MovieName, #39, '´');
        if Pos('´', MovieName) > 0 then
        Delete (MovieName, Pos('´', MovieName), Length(TextBetween(Moviename, '´', ' ')) + 1);
// Needed for internat. special characters like german Umlaute
        MovieName := UTF8Encode(MovieName);
// Use FILMSTARTS.de internal search function to get working title-URL
        AnalyzePage('http://www.filmstarts.de/suche/1/?q='+UrlEncode(MovieName));
      end;
    end
  else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
end.
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks :)
J
Posts: 224
Joined: 2008-02-17 17:09:26

Update

Post by J »

Very tiny update to get director(s) again.

Just change:

line 259
from
Value := TextBetween(TextBody, 'E48">', '</span>');
to
Value := TextBetween(TextBody, '.html">', '</a>');

and line 264
from
Value := Value + ', ' + TextBetween(Textbody, 'E48">', '</span>');
to
Value := Value + ', ' + TextBetween(Textbody, '.html">', '</a>');


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

Post by antp »

Thanks, I updated version to 2.0.2 then
Post Reply