PHPBB_IMPORT_WARNING CODE_NEAR_LI
As luck would have it, it appears that themoviedb.org website has been experiencing some severe accessibility issues over the last few days. When I first sat down to make some mods to Mirans' original vbscript code on Wednesday, I got good results back... though even at that time the test movie query I was using (The Matrix) generated either current (4-20) or stale (4-18) data (in the <last_modified_at> tag). Weird... I didn't see any "news" post or anything like that acknowledging that they are having issues though, so I really have no idea what's going on... but as of yesterday, it wasn't just the api queries used by the script that were failing. Other parts of the website were throwing 503 - bad gateway errors and other things...
At any rate, since I had a good bit of XML output from previous queries from Mirans' original vbscript code... I just saved that to a file and loaded it into my script instead of the real search url. So, I'm reasonably sure that this version re-written in javascript should work as intended once themoviedb.org website queries start working again...
// ****************************** Change log ******************************
// 2010-12-30 v0.5 Initial Release
// 2011-01-02 v0.5.1 Added URI encoding for MovieTitle
// 2011-01-28 v0.5.2 Utilized DOpus rename funktions to extract MovieName
// 2011-04-21 v0.5.2j jscript release with error checking by steje
//
// ************************************************************************
Besides being re-written in javascript... there are also a few notable modifications to Mirans' original code:
[ul][li]There are several error checks added to the code, to log an error (to the Opus 'Output Window -> Log:Script Output') in a few cases - such as if themoviedb.org query doesn't return a valid XML response or the website is unreachable (could also be due to no internet connection though) and also an error if there are no search results from the website for the movie title that was queried on.[/li]
[li]TMDb queries generally seem to return multiple search results... that is - multiple "Movie Title" matches... for instance, a query on "The Matrix" returns 7 results, including "The Matrix", "The Matrix Reloaded", "The Matrix Revolutions", and "Matrix Dezionised" among others. It looks like the "best" match is generally returned as the first search result - but particularly if a user specifies the image size using the new option (mentioned below), and the first (most likely 'correct') movie search result for some reason does NOT contain an image of the user-specified size, then without some other precautions the new code would have potentially dropped into one of the 'other' ('incorrect') movie search results and basically save the wrong movies image. To prevent this, the new code limits the images it checks to just those included in the first movie search result... it's not something most users should ever really care about - and won't functionally behave any different than Mirans original script code which always saved the 'first' image out of all images returned amongst all the movie search results... just mentioning it here in case the TMDb website returns a first search result for a movie other than what the user intended. I guess that could happen if you had either an incorrect filename for your movie, or if the website just doesn't always interpret the filename correctly or return the 'best' match as the first search result. Anyhow, theres the thought process behind limiting the image match to just the first movie search results list of images...[/li]
[li]TMDb queries also generally seem to return multiple images for each search result... for instance, a relatively large image is often the first image returned with a size of "original". There are often "cover" and "thumb" image sizes as well - along with others. A control flag (MovieDB_PosterSize) has been added that let's you determine which "poster size" you want the script to save.
[code]// ************************************************************************
// * Options *
// ************************************************************************
var MovieDB_APIKey, MovieDB_Language, MovieDB_PosterSize, MovieDB_PosterUrl, MovieDB_Url;
MovieDB_APIKey = "2cc30e3146b2f44d504561e96cfb358e";
MovieDB_Language = "en";
// Flag to control preferred image size, look at the XML output for ideas
// about the different size categories TMDb seems to use, i.e. original,
// cover, thumb, etc... the default value of "0" will cause the script to
// save the first image returned in the list of images (of which there)
// will often be multiple sizes...
MovieDB_PosterSize = 0;
MovieDB_PosterUrl = "";
MovieDB_Url = "http://api.themoviedb.org/2.1/";[/code]
...by default, the value is set to 0 and causes the script to behave the same Mirans original code - which is that the script will save ~whatever the very first image is that is returned. I added this flag so that a.) in case the website returned arbitrary "first" images, the user could reasonably limit getting potentially wildly different image sizes saved, and b.) even if the website ALWAYS returns the large image size (tagged as "original") consistently as the first image, if a user prefers to save the smaller "cover" image, they can do so... eg. by changing the default MovieDB_PosterSize = 0; in the script to MovieDB_PosterSize = "cover";... If the user-specified size cannot be found, then the script defaults back to Mirans original codes behavior (it saves the first image in the list, same as the default MovieDB_PosterSize = 0; value).[/li][/ul]
Besides those changes, I've also included a sample 'button' (DCF file) in the archive along with th rename preset. It's similar to the button code posted above...
Lastly, only the errors are saved to the Opus Script Log - which you can view by turning on the Output Window from the Opus9 Tools menu... If you want to see more messaging about what the script code is doing, then as with Mirans original code, you change the value of the LogLevel variable up towards the top of the script from it's default LOG_WARN to LOG_DEBUG.
[code]// ************************************************************************
// * System *
// ************************************************************************
var LOG_DEBUG = 0;
var LOG_INFO = 1;
var LOG_WARN = 2;
var LOG_ERR = 3;
var LOG_ALERT = 4;
var LogLevel = LOG_WARN;[/code]
Thanks again to Miran for his original work, hope however many people liked his original script finds this useful - particularly any users on 64bit Win7 with special characters in their movie filenames ... though others may also find the new option to specify the image size useful as well.
Feedback welcome... enjoy!
Mirans MovieDB Poster DownloaderJS.zip (2.71 KB)