The calendar is gone.
Click here to view posts


Imdb api
I have created a Ruby code that gathers information from IMDB and presents it in a nice class. The code uses why's hpricot v0.4.76.
Creating an object. The HTML is only loaded once as long as you have the object.

movie=IMDB.new("monty python holy grail")
or 
menu=true
movie=IMDB.new("monty python holy grail",menu)


If using the IMDB class in a command line, the menu option will present you with the titles and years that are listed on the IMDB search site and you enter a number. If there is menu (default value is false) it will pick the first link found. If no links are found it raises an error

Now lets say you want to print the list of actors.

movie.actors.each{|name,role|
   p name+" starred in "+ movie.title+" as "+role+"\n"
}
.actors is a hash where the key is he actor's name and the hash is the list of roles(CVS).

Although most movies do not have a plot IMDB still tries to list one.

p "This movies plot might be like: "+movie.plot 


So far its not to hard. BUT BECKER!! I want the poster!
Have no FEAR (some what)!

movie.poster

This will return the a img html tag, I am working on making this better.

Some other things.

movie.director
movie.run_time
movie.year
movie.genres #an array
movie.mpaa #html with rating and reason 
movie.to_xml#ohh why would I do this?


IMDB has no published API. I have found no other sites providing a good API. So I made one.

http://stephenbeckeriv.com/movie/office_space
The title uses _ for spaces. You can also use %20 but I made it easy. You will have uri encode your titles.

Also if you are not getting the search result you want, try looking at the returning titles.
http://stephenbeckeriv.com/movie_titles/office_space

Please email me with comments and suggestions!

Gem to rails plugin
I most recently wrote a class to interface with IMBD.com. This class requires a library called hpricot. I locally gem install hpricot and create my code. I then added my code to my website. Do to the fact that I use shared hosting I do not have the proper rights to gem install my needed libraries. I could open a ticket with my hosting company, and wait for someone to get to it. Nah, I don't want to do that. I decided to look in to creating a plugin from a gem.

As it turns out most of the time you can.
This what I did to create a plugin for hpricot

    1)Make rails project
    2)ruby script/gen plugin hpricot
    3)Gem install
	a)If you can on the server change the gem root to a
	local file you have RW access to and gem install hpricot -i /path/you/can/write
	
	b)If you can not gem install on the server do it locally,but
	do not cross windows with linux (different flavors do not seem to matter
	to much)
    4) Locate the installed gem package
    5) Copy lib and ext from the gem to ror/vendor/plugins/hpricot/
    6) Should work like a champ.


I tried to do this with rmagik but it did not work. So its not 100% but it can be done. I am working on a rake command, much like rake rails, to create plugins from gems.

Imdb broken
My ruby script has failed me.
"http://ia.imdb.com/media/imdb/01/I/79/05/84m.jpg"
"#####################################"
undefined method `search' for nil:NilClass
	/home/sbecker/svn/code/imdb/trunk/IMDB.rb:72:in `get_cast_html'
	/home/sbecker/svn/code/imdb/trunk/IMDB.rb:197:in `actors'
	/home/sbecker/svn/code/imdb/trunk/IMDB.rb:362/home/sbecker/svn/code/imdb/trunk/IMDB.rb:72:in `get_cast_html': undefined method `search' for nil:NilClass (NoMethodError)
	from /home/sbecker/svn/code/imdb/trunk/IMDB.rb:197:in `actors'
	from /home/sbecker/svn/code/imdb/trunk/IMDB.rb:362
I will be picking up development on this library again. No worries.

Imdb development
I have picked up the development of the IMDB class again! This is a pretty big rewrite. I currently have hpricot 0.5.136 installed and hope to update and test the code again. I still have to fix the date, actors list and to_xml. Then I will update my website to be an xml web service. I will be commenting the code and posting examples soon!

http://www.svn.stephenbeckeriv.com/code/imdb/trunk/

Imdb title search
I made the search for a title a class method. You will now call IMDB.title_search("high plains drifter") and receive a hash back. It use to be that you had to create a new IMDB object and then get the titles. I still support a movie.title_search but now wonder why you would do that. The hash is pretty interesting as well.

{"Titles (Exact Matches)"=>["Office Space"],
"Titles (Partial Matches)"=>["'Office Space': Out of the Office"],
"Popular Titles"=>["Office Space"],
"Titles (Approx Matches)"=>["Spice Girls: One Hour of Girl Power"]}

It will look something like that. I am thinking about stripping out the word title and the )('s but I have yet to write it.

The current supported methods are:
movie=IMDB.new(movie)# or office_space or OFFICE_SPACE or OFFICE+space 


pp movie.title

pp movie.poster_link

pp movie.rating

pp movie.aka

pp movie.also_known_as

pp movie.aspect

pp movie.aspect_ratio

pp movie.awards

pp movie.certification

pp movie.certifications

pp movie.certs

pp movie.color

pp movie.company

pp movie.country

pp movie.date

pp movie.director

pp movie.directors

pp movie.genre

pp movie.genres

pp movie.imdb_link

pp movie.keywords

pp movie.language

pp movie.mpaa

pp movie.page_html

pp movie.plot

pp movie.plot_keywords

pp movie.plot_outline

pp movie.poster_link

pp movie.rating

pp movie.ratings

pp movie.release_date

pp movie.runtime

pp movie.tagline

pp movie.user_comments

pp movie.writer

pp movie.writers

pp movie.title_search


pp IMDB.title_search("white strips")

Looks like a lot but write and writers returns the same things I just thought it would be nice to support both.

I added some comments about what each method should return and made it a little less fragile. I am going to start on supporting the actors list, but other then that I am done.

Imdb version high plains drifter
I am done! You can check the code out of the trunk of the SVN. The code has a few commented out tests. I thought about making test files for it but I do not want to hit IMDB to much. I support 2 boat loads of methods as compared to last reversion.

Gems says I am running hpricot 0.5.136 so I will try updating to the newest version of that and testing my code again. I hope that it will not matter. Other then that let me know if it breaks. I hope to have some sample code posted soon but, the hardest part of the sample code is coming up with a good example.

Imdb xml
My xml interface to movie data is up and running. Try it with this url http://stephenbeckeriv.com/movie/office_space. You should see a nice little piece of xml to be easily parsed later. I hope IMDB opens up their own interface soon.

New imdb idea
So I was reading some comments from dzone[1] about my imdb "api". I do not like that the imdb site can change and I am SOL until I fix the code. For what I use my imdb class for it is not an issue but for some other people it most likely will be an issue. I have started work on creating migration scripts and data loaders for the downloaded version of IMDB[2]. I hope this project does not join my my dead projects list[3].

Happy new year...

[1] http://dzone.com/links/ruby_imdb_api.html
[2] http://www.imdb.com/interfaces
[3] http://stephenbeckeriv.com/dead_projects