

Your own movie database in 5 minutes with IMDb API and Perl - bbelderbos
http://bobbelderbos.com/2011/11/movie-database-imdb-api-perl/

======
cabirum
Why not just download original db files from <http://www.imdb.com/interfaces>
? I mean parsing the whole db through the API may not be a good idea. There's
a tool (<http://www.jmdb.de/>) which parses the tables you need to mysql or
postgre.

~~~
1010010111
Wow. Props to AMZN. How long have these files been available?

I prefer to use my own choice of parsing tools and database software and
really appreciate provision of raw files like this.

But I'm not sure what the purpose of requiring attribution is if the data can
only be used for personal use. Assuming we comply with the license and do not
share the data, who else besides the user is going to see it?

If a user builds a better movie database with this data, he must not share it
with the world or even his neighbor. Sorry, them's the rules.

~~~
ig1
Since IMDB started, it was originally a volunteer contributed project.

~~~
10101010101
Interesting.

So, 1\. the text files have long been publicly available, since before the
acquisition and 2\. it was not a commercial project prior to acquistion.

Who wrote the non-commercial license? Was that also written before the
acquisition?

~~~
ig1
Wikipedia has the history of imdb:

<http://en.wikipedia.org/wiki/Internet_Movie_Database>

~~~
10101010101
User-generated content. Make a list of factual information. Accept submissions
from users. Watch it grow. Then partner with a large company to sell products.
And sell licenses to the data for $15K/year. (Give the top contributers a
"free" membership to something to keep them from suing you.) Yeah, that could
work.

Movie information, restaurant reviews, video clips, you name it. The miracle
of user-generated content.

------
szabgab
Unfortunately that Perl code is not a good representative of how one should
write Perl in 2011.

~~~
gglanzani
Do you care rewriting it for us(me)? Just curious for how perl should look
like now

~~~
peteretep
I'm a complete cowboy, and would probably write something like:
<http://pastebin.com/mvjTG9XG>

Edit: spot where I missed a comma :-P

~~~
autarch
Don't quote the variables, use placeholders. It's much simpler, and it's
safer.

$dbh->do( 'INSERT INTO movie_collection VALUES ( ?, ?, ... )', undef, @{
$data->{movie} }{@fields} );

~~~
peteretep
Sure. Where's the dbh coming from in this example though? And how do I get it
out again nicely to print the SQL to the command line?

~~~
rjbond3rd
It doesn't exist in the example, which is only creating the INSERT statements,
presumably to pipe into, e.g., the mysql command line client:

mysql -u user -p < inserts.sql

If the $dbh were in the example, then:

(a) you could avoid that (eek!) archaic escapeSingleQuote() sub, e.g., my
$released = $dbh->quote($released), but much better:

(b) as mentioned, use the SQL placeholders to avoid quoting altogether, but

(c) if you really want to print the INSERT's, just do method (a). Start by
declaring the $dbh, e.g. for MySQL:

my $dbh = DBI->new( 'DBI:mysql:my_db', 'db_user', 'db_pass');

------
anonova
If anyone is looking for a movie database with a less strict terms of use,
check <http://www.themoviedb.org/>

This is the service "used by many popular media centers like Moovida, XBMC,
Plex, MythTV and MediaPortal."

They have a pretty nice API too. <http://api.themoviedb.org/2.1/>

------
pavel_lishin
Argh, a screenshot of code.

~~~
tristanperry
The code is linked in a few places:

<http://bobbelderbos.com/src/moviecollection/getMovieData>

It is annoying though; a link doesn't do those using screenreaders (or search
engine bots!) much good.

------
patrickk
Interesting. I've got a big XBMC media setup, and scraping metadata from a
local source could certainly speed things up nicely instead of downloading
from IMBD constantly.

See:

[http://lifehacker.com/5536963/the-ultimate-start-to-
finish-g...](http://lifehacker.com/5536963/the-ultimate-start-to-finish-guide-
to-your-xbmc-media-center)

In particular:

[http://lifehacker.com/5505849/how-to-whip-your-movie-and-
tv-...](http://lifehacker.com/5505849/how-to-whip-your-movie-and-tv-show-art-
into-shape-for-xbmc-and-boxee)

------
ImprovedSilence
I found this really cool. last night I knew nothing about Perl or mySQL, and
just working through little things like this can really get you going on
learning code and just grasping a basic understanding of the syntax. But no
PHP code linked, just a video shot? I was hoping to get that part going as
well.

~~~
bbelderbos
thank you. I uploaded a the php code of the example site you saw in the video:
<http://bobbelderbos.com/src/moviecollection/site_php>

~~~
ImprovedSilence
Awesome, thanks. I saw lots of other interesting hacks on your blog too, I
intend to play around with some of them, it's really the best motivator for me
when it comes to learning programming.

~~~
bbelderbos
I am glad to hear that. Just let me know (via my contact form) if you have any
questions, feedback or interesting topics I could investigate. thanks

------
danso
The terms and conditions seem pretty clear that you can't save site content
except for page caching: <http://www.imdb.com/help/show_article?conditions>

>IMDb grants you a limited license to access and make personal use of this
site and not to download (other than page caching) or modify it, or any
portion of it, except with express written consent of IMDb. This site or any
portion of this site may not be reproduced, duplicated, copied, sold, resold,
visited, or otherwise exploited for any commercial purpose without express
written consent of IMDb. This license does not include any resale or
commercial use of this site or its contents or any derivative use of this site
or its contents.

(and no, I'm not trying to be a negative nancy. I've wanted to analyze imdb
for awhile but have known that it's not possible to do so without breaking
TOC)

~~~
dashr
anyone know of a good place to get Movie data (and possibly Cast/Crew) info
for free or low cost for a commercial project?

~~~
pyre
themoviedb

~~~
phaylon
There's also a CPAN DIstribution for that: <https://metacpan.org/release/TMDB>

------
bbelderbos
thanks all for your feedback. this is just for personal use. thanks for the
perl suggestions, I am just learning

