script/imdb-title.pl untested

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 60 SCAR 17.9
CC
2
Cov
0%
DumpTitle
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 6.0
1 #!/usr/local/bin/perl
2  
3 use strict;
4 use Getopt::Long;
5  
6 use IMDB::Local;
7  
8 my ($opt_help,
9 $opt_imdbDir,
10 $opt_import,
11 $opt_quiet,
12 $opt_download);
13 my $opt_title;
14  
15 GetOptions('help' => \$opt_help,
16 'imdbdir=s' => \$opt_imdbDir,
17 'import=s' => \$opt_import,
18 'quiet' => \$opt_quiet,
19 'title=s' => \$opt_title,
20 ) or usage(0);
21  
22 if ( $opt_help ) {
23 die "no usage implemented";
24 }
25  
26 if ( ! defined($opt_imdbDir) ) {
27 die "imdbdir flag is required";
28 }
29  
30 $opt_quiet=(defined($opt_quiet));
31  
32 # lets put list files below the imdbDir
33 my $listsDir="$opt_imdbDir/lists";
34  
35 my $db=new IMDB::Local::DB(database=>"$opt_imdbDir/imdb.db");
36 if ( !$db->connect() ) {
37 die "moviedb connect failed:$DBI::errstr";
38 }
39  
40 use IMDB::Local::Title;
41  
42 my $searchableTItle=$db->makeSearchableTitle($opt_title);
43 print "searching for $searchableTItle\n";
44  
45 sub DumpTitle($)
46 {
47 my ($t)=@_;
48  
49 #my $ind=" " x $index;
50 print $t->toText();
51
52 if ( $t->QualifierType->Name eq 'tv_series' ) {
53 #print "getting episodes..\n";
54
55 my $n=0;
56 for my $e ($t->getEpisodes()) {
57 $n++;
58 print "=====Episode #$n:\n";
59 $e->populateAll();
60 for (split("\n", $e->toText())) {
61 print "\t".$_."\n";
62 }
63 #print $e->toText();
64 }
65 }
66 }
67  
68 my @list=IMDB::Local::Title::findBySearchableTitle($db, $searchableTItle, 0); # any type
69 for my $i (@list) {
70 print "===============================: Title $i\n";
71  
72 my $t=IMDB::Local::Title::findByTitleID($db, $i);
73 $t->populateAll();
74
75 DumpTitle($t);
76
77 }
78  
79 exit(0);