Codyd has asked for the wisdom of the Perl Monks concerning the following question:

I'm working on a DVD database and like the php script VideoDB but I dident want to add in movies one by one since I have over 700 titles. So i started working on a script to take a TXT file and query IMDB using IMDB::Film and get the data on each movie in my list and writ it to another TXT file. I can then inport this into MySQL Im new to using perl for file minipulation so I'm taking it slow.. here is what i got so far
use IMDB::Film; $inputfile="dvdlist.txt"; $outputfile="dvdlist.csv"; open(INFILE,"$inputfile") or die("Couldn't open $inputfile\n"); open(OUTFILE,">$outputfile") or die("Couldn't open $outputfile\n"); @DVDS=<INFILE>; close (INFILE); foreach $line (@DVDS) { print "$line"; $imdbObj = new IMDB::Film(crit => "$line"); print OUTFILE "Title: ".$imdbObj->title()."\n"; print OUTFILE "Year: ".$imdbObj->year()."\n"; print OUTFILE "Plot Symmary: ".$imdbObj->plot()."\n"; }
The problem I'm having is when I run it against the dvdlist.txt file which looks like this.
Shaun Of The Dead Halfbaked aliens
it gives me an out put like this
Title: Shaun of the Dead Year: 2004 Plot Symmary: A man decides to turn his moribund life around by winnin +g back his ex-girlfriend, reconciling his relationship with his mothe +r and dealing with an entire community that has returned from the dea +d to eat the living. Title: Year: Plot Symmary: The story of three not so bright men who come up with a +series of crazy schemes to get a friend out of jail. Title: Year: Plot Symmary: The planet from Title: Year: Plot Symmary: Naive young Mormon Joe Young is recruited to act in porn + movies.
So it process the first title but it looks like the loop is not working for the others..any suggestions?

Replies are listed 'Best First'.
Re: Loop with IMDB::Film
by Aristotle (Chancellor) on Dec 25, 2004 at 23:48 UTC

    You are a bit quick to draw conclusions there. It processes “Shaun Of The Dead” fine, but not the others, regardless of the order in which they appear. The module's screen scraper is probably broken.

    Makeshifts last the longest.

      its just weird because it gets the Plot for the movies in the list but not the titles or year.. I never thought it might be the module. Ill see is there is a newer ver in CVS on CPAN. Thanks Aristotle
Re: Loop with IMDB::Film
by insaniac (Friar) on Dec 26, 2004 at 10:25 UTC
    meri kurimasu!

    If you use the movie code instead of the title, all works well. so you could first lookup the code, and then perform a query based on that code. The queries are also much much faster when searching on the movie code.

    And i think something's wrong with module ( IMDB::Film ). When i tried to CPAN it, it choked on some of the online tests, when it tried to receive the title of the movie "Troy"... it got an undef... like you get ;-)

    hope this helps a bit..

    --
    to ask a question is a moment of shame
    to remain ignorant is a lifelong shame
      I really appreciate all the help on this.. Im going to contiinue to work on this. My main problem is I do not have the IMDB "ID" for each movie .. actually that is what im trying to acomplish with the script. I have a list of movies and I need to search by title to retrive all the movies information. I'll keep tinkering with it and let you guys know what happends. Cody
      ok .. i found the problem with the title search. I don't know why i dident think of this. If i do a search for the movie "halfbaked" I get 1. Half Baked (1998) 2. Half-Baked Alaska (1965) 3. Half-Baked Relations (1934) so it returns an error because it dosent know what one to pick. At least as far as I can tell
Re: Loop with IMDB::Film
by redhotpenguin (Deacon) on Dec 26, 2004 at 06:55 UTC
    Instead of writing the information to another textfile, why not create objects using Class::DBI and save those directly to the database? You can use the find_or_create method to avoid creating duplicates should you need to run the file more than once.
Re: Loop with IMDB::Film
by keymon (Beadle) on Dec 26, 2004 at 18:13 UTC
    I know this may be offtopic, but: since the IMDB database is public domain/open source, is there a server somewhere which can provide the data in a more structured (machine readable) format, instead of having to rely on screen scraping?
      I alwasy thought it would be cool to server up IMDB content in CDDB style. That way programs could grab currnet movie info from a stable source with uniform format. I bet IMDBs database distribution could be used for that.