Page 2 of 2

Posted: 2010-12-14 17:13:53
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).

Posted: 2010-12-14 18:13:07
by daws0n
Thanks antp! Here's hoping the script will be updated soon :)

Posted: 2010-12-17 03:26:36
by Necrocter
Wow, good news. I will rewrite the script right now :).

Posted: 2010-12-17 08:25:58
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.

Posted: 2010-12-17 13:43:21
by antp
:??: Isn't it supposed to use IMDB number?

Posted: 2010-12-17 14:26:19
by daws0n
Yes, that's what I thought...

Posted: 2010-12-17 17:02:28
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).

Posted: 2010-12-17 17:20:50
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...

Posted: 2010-12-18 12:37:13
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.

Posted: 2010-12-18 20:10:18
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.

Posted: 2010-12-18 21:30:47
by daws0n
No problems here :) Excellent work, thanks a lot!

Posted: 2010-12-18 22:43:44
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...

Posted: 2010-12-18 23:53:51
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.