devroom.io/content/posts/2009-06-07-imdb-0-3-0-now-including-console-utility-query-imdb-from-your-console.md

65 lines
2.5 KiB
Markdown
Raw Normal View History

2015-03-26 11:28:08 +00:00
+++
date = "2009-06-07"
title = "IMDB 0.3.0 now including console utility - query IMDB from your console"
tags = ["General", "imdb", "gem", "console"]
slug = "imdb-0-3-0-now-including-console-utility-query-imdb-from-your-console"
+++
With the release of <a href="http://rubyforge.org/frs/?group_id=8457&release_id=35280">IMDB 0.3.0</a>, a command-line utility is included!
Why is this awesome for you? Basically, because you can now query IMDB and process the results with any of the great GNU tools available to you like <code>grep</code>.
Let me show you:
<strong>Search IMDB</strong>
<pre lang="sh">$ imdb Star Trek
>> Searching for "Star Trek"
> 0060028 | Star Trek (1966) (TV series)
> 0796366 | Star Trek (2009)
> 0092455 | Star Trek: The Next Generation (1987) (TV series)
> 0112178 | Star Trek: Voyager (1995) (TV series)
> 0106145 | Star Trek: Deep Space Nine (1993) (TV series)
> 0117731 | Star Trek: First Contact (1996)
> 0084726 | Star Trek: The Wrath of Khan (1982)
> 0092007 | Star Trek IV: The Voyage Home (1986)
> 0079945 | Star Trek: The Motion Picture (1979)
> 0244365 | Enterprise (2001) (TV series)</pre>
For clarity, only the ten first search results are shown. I'm thinking of including an option to set the number of returned titles. Let me know what you think about that.
<strong>Getting movie details</strong>
So, let's pick a movie we want to get details about.
<pre lang="sh">$ imdb 0796366
>> Fetching movie 0796366
Star Trek (2009)
========================================================================
Rating: 8.4
Duration: 127 minutes
Directed by: J.J. Abrams
Cast: Chris Pine, Zachary Quinto, Leonard Nimoy, Eric Bana, Bruce Greenwood
Genre: Action, Adventure, Sci-Fi
A chronicle of the early days of James T. Kirk and his fellow USS Enterprise crew members. |
========================================================================</pre>
<strong>Combine with GNU commands</strong>
Or, as mentioned earlier, you can combine it with other console commands. So to get the rating of a movie, do this:
<pre lang="sh">$ imdb 0796366 | grep "^Rating" | cut -d" " -f 2
8.4</pre>
<strong>Installation, source and issues</strong>
I'm still working on perfecting the console output, so if you have any tips, please <a href="http://github.com/ariejan/imdb/issues">report it in the form of an issue</a>.
You can get this as a Ruby Gem with
<pre lang="sh">sudo gem install imdb</pre>
The source is also available at <a href="http://github.com/ariejan/imdb">http://github.com/ariejan/imdb</a>.