#!/usr/bin/perl -w use strict; use VideoMetaData; use TVTome; use Data::Dumper; my $vmd = VideoMetaData->new(); my $tvto = TVTome->new(); my $noplot = $vmd->getNoPlot(); my $dbh = DBI->connect("DBI:mysql:mythconverg:myth1", 'root', undef); my $sql = "update videometadata set plot = ?, userrating = 0, title = ? where intid = ?"; system("clear"); print "\n\nFound ".scalar(@$noplot)." results\n"; my $i=0; foreach my $thisshow (@$noplot) { system("clear"); # Make sense of arbitrary filenames here print "$i $thisshow->{title}\n"; print "Enter the show name for \"$thisshow->{title}\": "; my $mythshow=; print "Enter the Season: "; my $mythseason= ; print "Enter the Episode: "; my $mythepisode= ; $i++; chomp($mythshow); chomp($mythseason); chomp($mythepisode); # Go checkout TVTome now print "Searching for \"$mythshow\"..\n"; my $search = $tvto->find(show => $mythshow); print "Your search produced the following results:\n"; my $i=0; foreach (@$search) { ++$i; print "$i. $$_{show}\n"; } print "--------------\n"; print "Enter your choice: "; my $choice = ; die "Must enter a number" unless ($choice =~ /\d/); die "Invalid choice." unless ($choice < scalar(@$search)+1 ); my $show = $$search[($choice-1)]->{show}; print 'You have chosen: '.$show."\nSearching....\n\n"; my $epsearch = $tvto->getEPList(url => $$search[($choice-1)]->{url}); print "Select the episode that matches S${mythseason}E${mythepisode}:\n "; $i=0; foreach (@$epsearch) { ++$i; print "$i. $$_{seasonep} $$_{airdate} $$_{epname}\n"; } print "--------------\n"; print $mythshow.' - S'.sprintf("%02s",$mythseason).'E'.sprintf("%02s",$mythepisode).' - '.$$epsearch[($choice- 1)]->{epname}; print "\nEnter your choice: "; $choice = ; die "Must enter a number" unless ($choice =~ /\d/); die "Invalid choice." unless ($choice < scalar(@$epsearch)+1 ); my $episode = $$epsearch[($choice-1)]->{epname}; print 'You have chosen episode: '.$episode."\nSearching....\n\n"; my $synopsis = $tvto->getSynopsis(url => $$epsearch[($choice-1)]->{epurl}); print "Synopsis for $show, \"$episode\":\n"; print $$synopsis; print "\n"; print "Length of synopsis: ".length($$synopsis); print "\nIt doesnt seem to be available!\n" unless (length($$synopsis) > 24); $$synopsis = "None" unless (length($$synopsis) > 24); print "Insert this into mythconverg.videometadata? [y|n]"; $choice = ; if ($choice =~ /y/i) { print "\n Add synopsis for $show, \"$episode\":\n"; my $sth = $dbh->prepare( $sql ) || die $dbh->errstr; my $title = $mythshow.' - S'.sprintf("%02s",$mythseason).'E'.sprintf("%02s",$mythepisode).' - '.$$epsearch[($choice-1)]->{epname}; print "Changing name to $title\n"; $sth->execute($$synopsis, $title, $thisshow->{intid}); } else { print "Skipping synopsis for $show, \"$episode\":\n"; } }