IMDB Fetcher – Experimental IMDB JavaScript and PHP API

Recently I came up with the idea to create my personal movie library that runs over the local intranet, and I was sure that IMDB provides some service that I can use to fetch movie data from their servers. I was really disappointed that such popular and huge website is well behind the current trends by not providing an external API of any kind. Eventually I checked for alternatives on the Internet, and actually I found a couple of cool solutions, but finally I decided to create one of my own, and the result is IMDBFetcher.

IMDBFetcher makes possible cross-domain AJAX queries to IMDB and returns a JSON data object for the requested movie. What is currently supported – movie title, poster, release date, description, actor(s), director(s), IMDB and MPAA rating, running time, etc. There is a really thin PHP layer which is solely responsible to make the crossdomain request of getting the HTML page locally, strip some white space and send it g-zipped to the client. The actual conversion from HTML to JSON is done on the client via regular expressions. The final result looks like this:

{
    "title": "Scarface",
    "starring": [
        "Al Pacino", "Michelle Pfeiffer", "Steven Bauer"
    ],
    "directors": ["Brian De Palma"],
    "year": "1983",
    "rating": "8.2",
    "poster": "http://ia.media-imdb.com/images/M/MV5BMTQ5NzI3OTQ3NF5BMl5BanBnXkFtZTcwODczMjMzMQ@@._V1._SY317_CR4,0,214,317_.jpg",
    "description": "In 1980 Miami, a determined Cuban immigrant takes over a drug cartel while succumbing to greed.",
    "genres": ["Crime", "Drama", "Thriller"],
    "mpaaRating": "R",
    "releaseDate": "9 December 1983 (USA)",
    "runningTime": "170 min",
    "result": "success"
}

… And is stored on the client in the form of key/value paired data objects, which can then be (re)used locally. IMDB restricts hotlinking of images from their servers, so I also had to write a small PHP function that returns a local copy of the movie poster which can be used when rendering the movie JSON object to HTML on the page. Please, refer to the “Using the Image Proxy” chapter on the documentation page for IMDBFetcher to learn how to use it.

Key Features

  • Provides simple to use movie data API from IMDB and returns a native JSON object ready for rendering on the client.
  • Gzips and strips white space and other crap from the original page, and returns a simple native JSON object.
  • Fully ajax-driven, no page reloads.
  • Features convenient API methods for retrieving local or remote data, and for deleting local movie data.
  • A bonus script for getting posters from IMDB locally (due to the restricted hotlinking policy of IMDB) is included.
  • Very fast, responsive and extremely easy to use.

Downside of IMDBFetcher

The major downside is that IMDBFetcher is fully dependent on the DOM provided by IMDB. If IMDB changes the markup of their pages, then IMDBFetcher will stop working, but anyway it can be fixed pretty fast on my side, and I will release an updated version.

Supported Browsers

Mozilla Firefox, Google Chrome, Apple Safari, Opera, Internet Explorer 9/10. IMDBFetcher does not initialize on older versions of Internet Explorer (6-8).

Now… What?

If you like the idea, you can give it a try – just check the demo, download it if you like it and learn how to use it by visiting the IMDBFetcher’s documentation page. If you are looking for other cool solutions or web UI components, you can check Acid.JS Web.UI and get the entire suite from this link.

Related Posts

14 comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>