6 ms·
Your own movie database in 5 minutes with IMDb API and Perl
- szabgab 15y agoUnfortunately that Perl code is not a good representative of how one should write Perl in 2011.
- gglanzani 15y agoDo you care rewriting it for us(me)? Just curious for how perl should look like now
- peteretep 15y agoI'm a complete cowboy, and would probably write something like: http://pastebin.com/mvjTG9XG http://pastebin.com/mvjTG9XG Edit: spot where I missed a comma :-P
- eCa 15y agoI don't have time for that.. Looks good though, much more readable.
- autarch 15y agoDon'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 15y agoSure. 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 15y agoIt 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');
- pyre 15y ago> knee-jerk reaction Fixed that for you.
- pyre 15y agoMade the SQL portion a little more readable: http://pastebin.com/MNzD0NSE http://pastebin.com/MNzD0NSE
- rjbond3rd 15y agoAh, much better. [It doesn't need saying but one could be even lazier and instead of generating a timestamp, one could use NOW() or an automatic timestamp field.]
- pavel_lishin 15y agoArgh, a screenshot of code.
- tristanperry 15y agoThe code is linked in a few places: http://bobbelderbos.com/src/moviecollection/getMovieData 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 15y agoInteresting. 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-guide-to-your-xbmc-media-center http://lifehacker.com/5536963/the-ultimate-start-to-finish-g... In particular: http://lifehacker.com/5505849/how-to-whip-your-movie-and-tv-show-art-into-shape-for-xbmc-and-boxee http://lifehacker.com/5505849/how-to-whip-your-movie-and-tv-...
- deleted 15y ago[deleted]
- cabirum 15y agoWhy not just download original db files from http://www.imdb.com/interfaces 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/ http://www.jmdb.de/) which parses the tables you need to mysql or postgre.
- 1010010111 15y agoWow. 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.
- jc4p 15y agoWhy are you giving props to Amazon?
- 1010010111 15y agoBecause I believe they acquired IMDb many years ago and would have the final say in how the data may be used.
- bgaluszka 15y agoFiles've been there before acquisition
- ig1 15y agoSince IMDB started, it was originally a volunteer contributed project.
- 10101010101 15y ago
- danso 15y agoThe 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 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 15y agoanyone know of a good place to get Movie data (and possibly Cast/Crew) info for free or low cost for a commercial project?
- senthil_rajasek 15y agofreebase.com
- deleted 15y ago[deleted]
- iand 15y agoTry http://kasabi.com/dataset/linked-movie-database http://kasabi.com/dataset/linked-movie-database and http://kasabi.com/dataset/dbpedia http://kasabi.com/dataset/dbpedia
- pyre 15y agothemoviedb
- phaylon 15y agoThere's also a CPAN DIstribution for that: https://metacpan.org/release/TMDB https://metacpan.org/release/TMDB
- anonova 15y agoIf anyone is looking for a movie database with a less strict terms of use, check http://www.themoviedb.org/ 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/ http://api.themoviedb.org/2.1/
- bbelderbos 15y agothanks all for your feedback. this is just for personal use. thanks for the perl suggestions, I am just learning
- ImprovedSilence 15y agoI 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 15y agothank you. I uploaded a the php code of the example site you saw in the video: http://bobbelderbos.com/src/moviecollection/site_php http://bobbelderbos.com/src/moviecollection/site_php
- ImprovedSilence 15y agoAwesome, 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.
- deleted 15y ago[deleted]
- bbelderbos 15y agoI 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