(*************************************************** 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.