[REL] MoviePosterDB (Poster download)

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

Post by antp »

I did not test with the site, but I guess it will work :

Code: Select all

key := GetPage('http://update.antp.be/amc/scripts/services/movieposterdb.php?id=' + IMDBnumber);
Note that it works only with AMC's user agent, so the link above does not return anything if used in a web browser (except if you change the user agent).
daws0n
Posts: 53
Joined: 2005-02-04 13:53:18

Post by daws0n »

Thanks antp! Here's hoping the script will be updated soon :)
Necrocter
Posts: 9
Joined: 2009-09-13 12:00:57

Post by Necrocter »

Wow, good news. I will rewrite the script right now :).
Necrocter
Posts: 9
Joined: 2009-09-13 12:00:57

Post by Necrocter »

Well, almost done, I just have problems to get a correct key using the title of the movie when the movie has spaces like 'star wars'.

I let you the correct key for 'star wars' to see what's the problem, maybe something with the GET method.

$secret_key = substr(md5(secretkeystar wars), 10, 12);

generated key: 56305f09d5ff

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

Post by antp »

:??: Isn't it supposed to use IMDB number?
daws0n
Posts: 53
Joined: 2005-02-04 13:53:18

Post by daws0n »

Yes, that's what I thought...
Necrocter
Posts: 9
Joined: 2009-09-13 12:00:57

Post by Necrocter »

Yeah, it could use both, IMDB Number, and Title. The title isn't the best option because the API throws to most recent movie with that name. Let me know if you want to leave just the IMDB option (the old script use both).
daws0n
Posts: 53
Joined: 2005-02-04 13:53:18

Post by daws0n »

Agreed, I had that problem alot and stuck to using the IMDB number. Personally, I won't be sad to see it go - but I don't know about others...
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

If you use IMDB for the title search within the script I guess it is more reliable then, since IMDB's search engine is quite good.
Else, for the title, you may try to encode it with UrlEncode before passing it to GetPage function.
Necrocter
Posts: 9
Joined: 2009-09-13 12:00:57

Post by Necrocter »

Here we go.

NOTE: If someone really needs to search by Movie Name let me know to implement this to the script, just remember that the MPDB API only throws the last movie made with that name, so isn't very realiable to use this method.

Code: Select all

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

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

[Infos]
Authors=Necrocter, daws0n
Title=MoviePosterDB
Description=Download posters from MoviePosterDB
Site=www.movieposterdb.com
Language=?
Version=0.2
Requires=3.5.1
Comments=The script needs a valid IMDB URL.
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
GetInfo=1

[Options]

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

program MoviePosterDB;
uses
  StringUtils1;
var
  IMDB: string;  // Stores the imdb number
  KEY: string; // Stores the key to use the API
  MPDBURL: string; // Stores the url to parse

procedure AnalyzePage(Address: string);

var
   PageText: string;
   Value: string;
   
begin
   
  PageText := GetPage(Address);
 
  if Pos('{"errors":["No parameters found..."]}', PageText) > 0 then
    begin
      ShowMessage('No movie found for this search');
      Exit;
    end

  Value := TextBetween(PageText, '"image_location":"', '"}');
  Value := StringReplace(Value, '\', '');
  GetPicture(Value);
end;

//** The main rutine **/
begin
  if CheckVersion(3,5,0) then
    begin
      IMDB := '';
      IMDB := GetField(fieldURL);
      if Pos('imdb', IMDB) > 0  then
        begin
          IMDB := TextAfter(IMDB, 'title/tt');
          IMDB := IntToStr(StrToInt(IMDB,0));
          KEY := GetPage('http://update.antp.be/amc/scripts/services/movieposterdb.php?id=' + IMDB);
          MPDBURL := 'http://api.movieposterdb.com/json?imdb_code=' + IMDB + '&api_key=antmovcat&secret=' + KEY + '&width=300&callback=process';
        
          AnalyzePage(MPDBURL);
        end
      else
        begin
          ShowMessage('You need a valid IMDB URL in the URL field to use this script.');
        end
    end
  else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
end.
daws0n
Posts: 53
Joined: 2005-02-04 13:53:18

Post by daws0n »

No problems here :) Excellent work, thanks a lot!
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks :)

I added this in case there is a "/" (and possibly other stuff) after the number in the URL, as that case is quite likely:

Code: Select all

          if(Pos('/', IMDB) > 0)
            IMDB := TextBefore(IMDB, '/', '');
I also modified a little the test at the beginning so it asks for IMDB url in case it is not found in the URL field.

It would be good to include the title search from IMDB script...
Necrocter
Posts: 9
Joined: 2009-09-13 12:00:57

Post by Necrocter »

antp wrote:Thanks :)

I added this in case there is a "/" (and possibly other stuff) after the number in the URL, as that case is quite likely:

Code: Select all

          if(Pos('/', IMDB) > 0)
            IMDB := TextBefore(IMDB, '/', '');
I also modified a little the test at the beginning so it asks for IMDB url in case it is not found in the URL field.

It would be good to include the title search from IMDB script...
Oh, thx for the corrections, and about the the title search from IMDB script is a great idea, I will work on that feature.
Post Reply