MovieMeter (NL) : Script adaptation to get the poster

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.
umac6
Posts: 1
Joined: 2011-11-17 13:01:29

MovieMeter (NL) : Script adaptation to get the poster

Post by umac6 »

Hello, i could not find the way to upload scripts so i'll pass it onto the forum :

MovieMeter has change their image tag so you need to change the search for the poster to : img itemprop="image"

Full working script :

Code: Select all

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

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

[Infos]
Authors=Antoine Potten
Title=MovieMeter.nl
Description=MovieMeter.nl import script
Site=www.moviemeter.nl
Language=NL
Version=2.7.7
Requires=3.5.0
Comments=Fixed by tsjarlie / Miss_Kitty (v 2.7.3)|Fixed by Kaas (v 2.7.1)|Updated/Fixed by bad4u (v 2.7)|Previous version made by JanC and corrections by <link>rolandb5@hotmail.com</link>, rewritten by Antoine Potten after a site change (v 2.0)
License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
GetInfo=1

[Options]
AllCountries=0|0|0=Take only first country|1=Take all countries (separated by "/")
ImportComments=0|0|0=Do not import users' comments|1=Import users' comments

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

program MovieMeter;

uses
  StringUtils1;

var
  MovieName: string;

procedure AnalyzeMoviePage(Address: string);
var
  PageText, Line, Value: string;
begin
  PageText := GetPage(Address);

  // URL
  SetField(fieldURL, Address);

  // title & year
  Line := TextBetween(PageText, '<h1>', '</h1>');
  Value := TextBetween(Line, '(', ')');
  SetField(fieldYear, Value);
  Value := Trim(TextBefore(Line, '(', ''));
  HTMLDecode(Value);
  SetField(fieldOriginalTitle, Value);

  // translated title
  Line := TextBetween(PageText, 'Alternatieve titel', ' </p>');
  if Line <> '' then
  begin
    Line := TextAfter(Line, ': ');
    if Line <> '' then
    begin
      HTMLDecode(Line);
      SetField(fieldTranslatedTitle, Line);
    end;
  end;

  Value := TextBetween(PageText, '<div id="film_info"', '<br />');
  Line := RemainingText;
  Value := TextAfter(Value, '</div>');
  HTMLRemoveTags(Value);
  Value := Trim(Value);

  // Country
  if (GetOption('AllCountries') = 0) and (Pos(' / ', Value) > 0)  then
    Value := TextBefore(Value, ' / ', '');
  HTMLDecode(Value);
  SetField(fieldCountry, Value);

  // Category
  Value := TextBefore(Line, '<br />', '');
  Line := RemainingText;
  HTMLDecode(Value);
  SetField(fieldCategory, Value);

  // Length
  Value := TextBefore(Line, ' minuten', '');
  Line := RemainingText;
  HTMLDecode(Value);
  SetField(fieldLength, Value);

  // Director
  Value := TextBetween(Line, 'geregisseerd door ', '<br />');
  Line := RemainingText;
  HTMLRemoveTags(Value);
  HTMLDecode(Value);
  SetField(fieldDirector, Value);

  // Actors
  Value := TextBetween(Line, 'met ', '<br />');
  Line := RemainingText;
  HTMLDecode(Value);
  SetField(fieldActors, Value);

  // Description
  Value := TextBetween(Line, '<br />', '</div>');
  HTMLRemoveTags(Value);
  HTMLDecode(Value);
  SetField(fieldDescription, Value);

  // Picture
  Value := TextBetween(PageText, '<img itemprop="image" id="poster" class="poster" src="', '" ');
  if Value <> '' then
  begin
    GetPicture(Value);
  end;

  // Rating
  Value := TextBetween(PageText, '</span>gemiddelde <b>', '<');
  Value := StringReplace(FloatToStr(StrToFloat(StringReplace(Value, ',', '.')) * 2), ',', '.');
  SetField(fieldRating, Value);

  // Comments
  if GetOption('ImportComments') = 1 then
  begin
    Value := TextBetween(PageText, '<div class="forum_message_user">', '<div class="to_page entitypages" id="pages_bottom"></div>');
    Value := StringReplace(Value, ' uur', ' uur :  ' + #13#10);
//    Value := StringReplace(Value, '<div class="forum_message_message">', #13#10);
    Value := StringReplace(Value, '</div><div class="form_horizontal_divider" ', '-------------------------------------------------------------' + #13#10 + #13#10 + '<');
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    SetField(fieldComments, Value);
  end;

end;


procedure AnalyzeResultsPage(Address: string);
var
  Page: TStringList;
  Line: string;
  MovieAddress: string;
  MovieTitle: string;
  aantal : integer;
begin
  // get results page
  aantal := 0;
  Page := TStringList.Create;
  Page.Text := GetPage(Address);

  // get redirect javascript
  Line := Page.GetString(Page.Count-2);

  // more than 1 movie found
  if Pos('location.replace("http://www.moviemeter.nl/film/searchresults#results");', Line) <> 0 then
  begin
    PickTreeClear;
    PickTreeAdd('Zoekresultaten voor ' + MovieName, '');

    // get results page
    Page.Text := GetPage('http://www.moviemeter.nl/film/searchresults#results');
    if Pos('Populaire zoekresultaten in films:', Page.Text) > 0 then
      Line := TextBetween(Page.Text, 'Populaire zoekresultaten in films:</p>', '<form action="http://www.moviemeter.nl/film/search/"');
    if Pos('Alle zoekresultaten in films:', Page.Text) > 0 then
      Line := TextBetween(Page.Text, 'Alle zoekresultaten in films:</p>', '<form action="http://www.moviemeter.nl/film/search/"');
    if Pos('Zoekresultaten in films:', Page.Text) > 0 then
      Line := TextBetween(Page.Text, 'Zoekresultaten in films:</p>', '<form action="http://www.moviemeter.nl/film/search/"');
    Line := TextBetween(Line, '</p></div>', '<p><br /></p>');
    while Pos('filmresults_row', Line) > 0 do
    begin
      MovieAddress := TextBetween(Line, 'href="', '" >');
      MovieTitle := TextBefore(Line, '</p></div>', '');
      Line := RemainingText;
      HTMLRemoveTags(MovieTitle);
      HTMLDecode(MovieTitle);
      PickTreeAdd(Trim(MovieTitle), MovieAddress);
      aantal := aantal + 1;
    end;
    if aantal = 0 then
     begin
      ShowMessage('Geen resultaten gevonden...');
      Page.Free;
      exit;
     end;
    // if user picks a movie from the results list, import movie details
    if PickTreeExec(Address) then
      AnalyzeMoviePage(Address);
  end
  else
  begin
    MovieAddress := TextBetween(Line, '("', '");');
    if MovieAddress <> 'http://www.moviemeter.nl/film/' then
      // if only 1 movie found --> redirect to movie page
      AnalyzeMoviePage(MovieAddress)
    else
      // no movies found
      ShowMessage('Geen zoekresultaat voor "'+MovieName+'".');
  end;
  Page.Free;

end;


begin
  if CheckVersion(3,5,0) then
  begin
    if StringUtils1_Version >= 2 then
    begin
      MovieName := GetField(fieldOriginalTitle);
      if MovieName = '' then
        MovieName := GetField(fieldTranslatedTitle);
      if Input('MovieMeter.nl Import', 'Geef de titel van de film:', MovieName) then
      begin
        AnalyzeResultsPage('http://www.moviemeter.nl/film/search/'+UrlEncode(MovieName));
      end;
    end
    else
      ShowMessage('The file "StringUtils1.pas" is outdated, please find a new version of it (at least version 2)');
  end
  else
    ShowMessage('Dit script vereist een nieuwere versie van Ant Movie Catalog (minstens versie 3.5.0)');
    exit;
end.
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Hi,
This script is identical to the one currently on the server :??:
wvd
Posts: 96
Joined: 2006-08-02 22:21:20
Location: Nederland

Post by wvd »

Hello, there is more wrong: Titel, Rating, Category, Actors

I've tried to change the script and by my surprice it works nearly good,
I don't know if I did it the right way.
But there is one thing I can't get good and that's the "actors"

Can somebody correct the changed script please.

Thanks a lot :grinking: :grinking:
Greetings Wim


Here is the script how I changed it:

Code: Select all

program MovieMeter;

uses
  StringUtils1;

var
  MovieName: string;

procedure AnalyzeMoviePage(Address: string);
var
  PageText, Line, Value: string;
begin
  PageText := GetPage(Address);

  // URL
  SetField(fieldURL, Address);

  // title & year
  Line := TextBetween(PageText, '<h1 itemprop="name">', '</h1>');
  Value := TextBetween(Line, '(', ')');
  SetField(fieldYear, Value);
  Value := Trim(TextBefore(Line, '(', ''));
  HTMLDecode(Value);
  SetField(fieldOriginalTitle, Value);

  // translated title
  Line := TextBetween(PageText, 'Alternatieve titel', ' </p>');
  if Line <> '' then
  begin
    Line := TextAfter(Line, ': ');
    if Line <> '' then
    begin
      HTMLDecode(Line);
      SetField(fieldTranslatedTitle, Line);
    end;
  end;

  Value := TextBetween(PageText, '<div id="film_info"', '<br />');
  Line := RemainingText;
  Value := TextAfter(Value, '</div>');

  HTMLRemoveTags(Value);
Value := Trim(Value);

  // Country
  if (GetOption('AllCountries') = 0) and (Pos(' / ', Value) > 0)  then
    Value := TextBefore(Value, ' / ', '');
 HTMLDecode(Value);
  SetField(fieldCountry, Value);

  // Category
  Value := TextBetween(Line, '<span itemprop="genre">', '</span><br />');
  Line := RemainingText;
  HTMLRemoveTags(Value);
  HTMLDecode(Value);
  SetField(fieldCategory, Value);
  
  // Length
  Value := TextBefore(Line, ' minuten', '');
  Line := RemainingText;
  HTMLDecode(Value);
  SetField(fieldLength, Value);

  // Director
  Value := TextBetween(Line, 'geregisseerd door ', '<br />');
  Line := RemainingText;
  HTMLRemoveTags(Value);
  HTMLDecode(Value);
  SetField(fieldDirector, Value);

  // Actors
  Value := TextBetween(Line, 'met <span itemprop="actors">', '<br />');
  Line := RemainingText;
  HTMLDecode(Value);
  SetField(fieldActors, Value);

  // Description
  Value := TextBetween(Line, '<br />', '</div>');
  HTMLRemoveTags(Value);
  HTMLDecode(Value);
  SetField(fieldDescription, Value);

  // Picture
  Value := TextBetween(PageText, '<img itemprop="image" id="poster" class="poster" src=', '" ');
  if Value <> '' then
  begin
    GetPicture(Value);
  end;

  // Rating
  Value := TextBetween(PageText, '<span itemprop="ratingValue">', '<');
  Value := StringReplace(FloatToStr(StrToFloat(StringReplace(Value, ',', '.')) * 2), ',', '.');
  SetField(fieldRating, Value);

   // Comments
  if GetOption('ImportComments') = 1 then
  begin
    Value := TextBetween(PageText, '<div class="forum_message_user">', '<div class="to_page entitypages" id="pages_bottom"></div>');
    Value := StringReplace(Value, ' uur', ' uur :  ' + #13#10);
//    Value := StringReplace(Value, '<div class="forum_message_message">', #13#10);
    Value := StringReplace(Value, '</div><div class="form_horizontal_divider" ', '-------------------------------------------------------------' + #13#10 + #13#10 + '<');
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    SetField(fieldComments, Value);
  end;

end;


procedure AnalyzeResultsPage(Address: string);
var
  Page: TStringList;
  Line: string;
  MovieAddress: string;
  MovieTitle: string;
  aantal : integer;
begin
  // get results page
  aantal := 0;
  Page := TStringList.Create;
  Page.Text := GetPage(Address);

  // get redirect javascript
  Line := Page.GetString(Page.Count-2);

  // more than 1 movie found
  if Pos('location.replace("http://www.moviemeter.nl/film/searchresults#results");', Line) <> 0 then
  begin
    PickTreeClear;
    PickTreeAdd('Zoekresultaten voor ' + MovieName, '');

    // get results page
    Page.Text := GetPage('http://www.moviemeter.nl/film/searchresults#results');
    if Pos('Populaire zoekresultaten in films:', Page.Text) > 0 then
      Line := TextBetween(Page.Text, 'Populaire zoekresultaten in films:</p>', '<form action="http://www.moviemeter.nl/film/search/"');
    if Pos('Alle zoekresultaten in films:', Page.Text) > 0 then
      Line := TextBetween(Page.Text, 'Alle zoekresultaten in films:</p>', '<form action="http://www.moviemeter.nl/film/search/"');
    if Pos('Zoekresultaten in films:', Page.Text) > 0 then
      Line := TextBetween(Page.Text, 'Zoekresultaten in films:</p>', '<form action="http://www.moviemeter.nl/film/search/"');
    Line := TextBetween(Line, '</p></div>', '<p><br /></p>');
    while Pos('filmresults_row', Line) > 0 do
    begin
      MovieAddress := TextBetween(Line, 'href="', '" >');
      MovieTitle := TextBefore(Line, '</p></div>', '');
      Line := RemainingText;
      HTMLRemoveTags(MovieTitle);
      HTMLDecode(MovieTitle);
      PickTreeAdd(Trim(MovieTitle), MovieAddress);
      aantal := aantal + 1;
    end;
    if aantal = 0 then
     begin
      ShowMessage('Geen resultaten gevonden...');
      Page.Free;
      exit;
     end;
    // if user picks a movie from the results list, import movie details
    if PickTreeExec(Address) then
      AnalyzeMoviePage(Address);
  end
  else
  begin
    MovieAddress := TextBetween(Line, '("', '");');
    if MovieAddress <> 'http://www.moviemeter.nl/film/' then
      // if only 1 movie found --> redirect to movie page
      AnalyzeMoviePage(MovieAddress)
    else
      // no movies found
      ShowMessage('Geen zoekresultaat voor "'+MovieName+'".');
  end;
  Page.Free;

end;


begin
  if CheckVersion(3,5,0) then
  begin
    if StringUtils1_Version >= 2 then
    begin
      MovieName := GetField(fieldOriginalTitle);
      if MovieName = '' then
        MovieName := GetField(fieldTranslatedTitle);
      if Input('MovieMeter.nl Import', 'Geef de titel van de film:', MovieName) then
      begin
        AnalyzeResultsPage('http://www.moviemeter.nl/film/search/'+UrlEncode(MovieName));
      end;
    end
    else
      ShowMessage('The file "StringUtils1.pas" is outdated, please find a new version of it (at least version 2)');
  end
  else
    ShowMessage('Dit script vereist een nieuwere versie van Ant Movie Catalog (minstens versie 3.5.0)');
    exit;
end.
StefMir
Posts: 55
Joined: 2011-05-31 19:07:43

Post by StefMir »

With the IMDB script you only have to import the urls to fill all fields.

Is it possible to change the moviemeter.nl script this way?

I have over 2000 movies and the url's from moviemeter are in my .csv file, but I have to manually point almost all the movies when I run this script.

I don't know how to change the moviemeter.nl script to work the same way and I hope someone can ....
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

@wvd > thanks, I took your code and just added a "HTMLRemoveTags" call in the actors processing block to fix that last bug, and uploaded the script as version 2.7.8 on http://update.antp.be/amc/scripts/

@StefMir >I added a "batchmode" option (at the right of the script list, double click on the option name to change it) that allows to skip the title selection if a moviemeter address if found in the URL field.
I hope it will help ;)
StefMir
Posts: 55
Joined: 2011-05-31 19:07:43

Post by StefMir »

Works great !!!!!!

Thank you both!!!

Now I got my 2000+ movies within' a few minutes updated with latest scores etc!!!!
wvd
Posts: 96
Joined: 2006-08-02 22:21:20
Location: Nederland

Post by wvd »

Thanx for fixing the problem Antoine :grinking: :grinking:
xandertje
Posts: 2
Joined: 2008-09-12 14:26:02

Post by xandertje »

Thanks both for fixing the problems

It works great :grinking: :grinking:
wvd
Posts: 96
Joined: 2006-08-02 22:21:20
Location: Nederland

Post by wvd »

Unfortunaly there's something wrong again.
I have tried but I can't fix it.

The "rating" and the "length" of the movies does not work anymore.

I hope someone can fix it.

Many thanks

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

Post by antp »

I fixed the rating recently, I'll check for the length

edit: fixed, uploaded on the server as version 2.8.01
wvd
Posts: 96
Joined: 2006-08-02 22:21:20
Location: Nederland

Post by wvd »

Antoine,

Thanks for fixing the problem so fast :grinking: :grinking:

Greetings
Wim
pele
Posts: 72
Joined: 2009-02-21 20:25:57

Post by pele »

Hi,

New script moviemeter is doing nothing. I does't find any film at all.

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

Post by antp »

Hi,
They changed the search page it seems.
I updated the script (version 2.8.02)
pele
Posts: 72
Joined: 2009-02-21 20:25:57

Post by pele »

thanks for the update script but movies beginning with the...are not be found. Perhaps you can look into it.

Kr. Bianca
DnDuffe
Posts: 6
Joined: 2012-01-02 17:27:02

Post by DnDuffe »

Same problem.
I updated the script (version of 2-1-2012) but it does not find anything on moviemeter. IMDB works fine.
Does anyone know they answer to this problem?

OR does anyone know another good alternative for moviemeter
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

It works with the few movies that I test... What movie do you try? Do you have the version 2.8.02? (version number is shown in the bottom panel when the script is selected)
DnDuffe
Posts: 6
Joined: 2012-01-02 17:27:02

Post by DnDuffe »

aha now it works for caged but
Return to the Hiding Place he can't find
Teebee
Posts: 111
Joined: 2005-06-04 10:46:56

Post by Teebee »

One more he can't seem to find, and is present on moviemeter:

The Big Red one (1980) http://www.moviemeter.nl/film/2284

tried to search for:
Big Red one
Big Red one, The
The Big Red one
The Big Red one (1980)
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

It failed when only one movie is found (because I did a search on the sentence "films gevonden die aan je zoekopdracht voldoen." which is of course different when there is only one :D )
Script fixed as version 2.8.03
pele
Posts: 72
Joined: 2009-02-21 20:25:57

Post by pele »

Hi,

The new version works, thanks.

Kr, Bianca
Post Reply