Well I was playing with the script editor from ant and then I realize that it was really easy to make scripts (the debug tool it makes the things easy).
I'm not familiar with Delphi so maybe my script is ugly and has a lot of bugs, but it works . The API from movieposterdb makes the thing easy too, you don't need to parse a complicate page to get the images.
The posters are not too big because the api doesn't let it, but the nice thing from this page is that I found a lot of rare movies.
It's preferably to have the imdb url in the URL field because if you use the names to get the covers the api will get the first movie that it will find with that name.
If someone could get an API key from TMDB (http://www.themoviedb.org/), I have time to make the script and it has bigger images.
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Necrocter
Title=MoviePosterDB
Description=Download posters from MoviePosterDB
Site=www.movieposterdb.com
Language=?
Version=0.1
Requires=3.5.1
Comments=Maybe some bugs will appear, let me know it.
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; // storage the imdb number
MovieName: string; // storage the movie name
const
// the maximum width of the image permitted by the API is 300
// I will change the script to use the properties to let the users
// change the value of the width between 30 and 300
IMDBURL = 'http://api.movieposterdb.com/json.inc.php?width=300&imdb=';
MOVIEURL = 'http://api.movieposterdb.com/json.inc.php?width=300&title=';
// Removes all the info about the movie and the '\' from
// the image url
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, '"imageurl":"', '"}');
Value := StringReplace(Value, '\', '');
GetPicture(Value);
end;
//** The main rutine **/
begin
if CheckVersion(3,5,0) then
begin
IMDB := '';
IMDB := GetField(fieldURL);
if Pos('imdb.com', IMDB) > 0 then
begin
IMDB := TextAfter(IMDB, 'title/tt');
AnalyzePage(IMDBURL + IMDB);
end
else
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
Input('Import cover from movieposterdb', 'Enter the title of the movie:', MovieName);
AnalyzePage(MOVIEURL + UrlEncode(MovieName));
end
end
else
ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
end.