YAMJ Trailer Downloader

In order to truly take advantage and make use of your Networked Media Tank/Popcorn Hour, you’ll definitely want to have trailers available for each of your movies.  However, since the NMT cannot run/display Flash movies natively, I don’t think anyone really wants to take the time to download (or transcode) trailers from YouTube to MP4′s manually, especially if you’ve got hundreds of movies like I do.

So what’s the solution?

YAMJ Trailer Downloader, written in PHP by yours truly.

Requirements & Dependencies

PHP (specifically to be used with command line interface) (http://www.php.net)

WGet for Windows (http://users.ugent.be/~bpuype/wget/)

Windows (any version that can run command line PHP should do the trick)

How It Works

This will essentially run through each folder in the specified directory (specified in the PHP script) and download trailers one-by-one.  Within the code, it runs like this:

PHP checks the directory for the existence of a .nfo file.

If the .NFO does not exist, this directory (or “movie”) is skipped, remembered & stored and the loop goes on to the next movie.

If the .NFO file does exist, it searches for the <trailer> tag.

If the trailer tag does not exist, this directory (or “movie”) is skipped and the loop goes on to the next movie.

If the trailer tag does exist, it determines whether the link to the trailer is a YouTube video or not.

If the trailer is not a Youtube link (i.e. Apple.com trailer), the URL provided is used as the “Trailer URL”.

If the trailer is a Youtube link, the script attempts to look for a 720P version of the video.

If the 720P version of the video is available, this video is used.

If a 720P version does not exist, a standard definition file is downloaded instead.

The filename of the video downloaded is the same as the .NFO file, but replaces .nfo with .[TRAILER].Mp4 (or the proper extension).

For example, if the .NFO file is named “Movie Title One.nfo”, the filename of the trailer is “Movie Title One.[TRAILER].MP4″ (or .MOV).

At the end of the process, all movies without .NFO’s or Trailer URL’s in their respective .NFO files are displayed for your reference, in the event that you’d like to look for the trailers on your own.

Once this is completed, run YAMJ (or whatever program you use to generate information pages for your device) and this will display trailers locally.

Usage

For those unfamiliar with running PHP files via command line, select “Run” from your start menu, and run the following command:

“php [Full Path to PHP file]\index.php”

For example, if your PHP file resides in “D:\Movies”, the proper command would be “php D:\Movies\index.php”.

Note

The full path to the movies should be included in the .PHP file, and should have double backslashes (because of the way that PHP uses that character as an escape character).

For example, if your path is “D:\Movies”, the path should be defined as “D:\\Movies”.  If the path is “D:\Downloads\Movies”, the path should be defined as “D:\\Downloads\\Movies”.

Download

Download YAMJ Trailer Downloader

Leave a Comment

Let us know your thoughts on this post but remember to place nicely folks!