themoviedb.org API and ColdFusion


Last week while hanging out in the #coldfusion IRC channel I came across a nifty new app called keyStream created by Cory Fail. In a nutshell, it is a ColdFusion application that allows you to stream your media to your devices while you are attached to your home network. This appeals to my tender sensibilities since I tend to watch movies online more than on a TV.

KeyStream is a great application, one thing that was missing for me was being able to hit an API to pull down movie metadata. If you have a lot of media files it is nice to have an automated way of scanning through a whole directory of files in one fell swoop ala XBMC or comparable media applications. With that in mind, I set to see how difficult it would be to interface with tmdb.org in ColdFusion and I found that it actually was not that difficult.

Here is the TMDBService object for ColdBox although it could easily be ported:

First step though is getting an API key. Cruise over to themoviedb.org and sign up for an API key. It is free so even us starving developers can afford it.

Doing a lookup basically requires two steps. First we will pass the movie name in as a string to the findMovie(name, year) function which goes to the APIs /search/movie endpoint. This will return a list of matches back from tmdb.org, if there is an exact match it will be pushed up to the top of the list. Assuming the first position is the movie we want it is time to go to the APIs /movie/{id} endpoint(getMovieData(id) function in the gist if you are following along), passing it the id we got in the first call. This is where we get all the fun stuff such as the poster and backdrop data, overview, release date and IMDB rating. If you would want to see it when viewing your media, this is where you would find it.

To speed the process up a little bit I created the scrape() method that fires these two calls in one swoop. It assumes it will always have an exact match in the movie title, things get a little hairy when there isn’t an exact match but this is still a work in progress.

 

The final step is to call the APIs /configuration endpoint if you are wanting to download the cover and background art. This data tells you where to look on their image server for the images since they are sorted out by size and then it is just a matter of making a cfhttp call out and downloading the images to your local server. Assuming there is enough interest I could provide a more detailed accounting of getting this done. The finished product could look something like this:

Advertisements

About Robert Zehnder

Web application developer specializing in ColdFusion/Railo and Open Source development.

Posted on June 29, 2014, in ColdBox, ColdFusion, Railo and tagged , , . Bookmark the permalink. 2 Comments.

  1. “I tend to watch movies online more than on a TV.”

    Me too. I also use ColdFusion, but prefer more robust media servers when it comes to watching videos on my LAN (or WAN). Check out Plex Media Server & Media Companion. Both are free.
    https://plex.tv/
    https://mediacompanion.codeplex.com/

    • I have used Plex before and currently I am using XBMC as my go to app for maintaining everything. Actually, I just checked out media companion in the last few days.

      Basically, this is just a little fun diversion 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: