lib/IMDB/Local.pm

filter: Statementstmt 2.7% 25 / 899 Branchbran 0.0% 0 / 522 Conditioncond 0.0% 0 / 104 MC/DCmcdc 0.0% 0 / 65 Subroutinesub 17.9% 7 / 39 Podpod 24.0% 6 / 25 totaltotal 2.3% 38 / 1654 CC 305 SCAR 68.6
CC
305
Cov
2%
importActors
2256.0
_importListFile
1722.0
importPlots
1332.0
CRAP 954.9
↑ Summary lib/IMDB/Local/DB/Base.pm »
1 package IMDB::Local;
2  
3 #
4 # Suggestions for improvements
5 # -
6 #
7 #
8  
9 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 =head1 NAME
14  
15 IMDB::Local - Tools to dowload and manage a local copy of the IMDB list files in a database.
16  
17 =cut
18  
19 1 our $VERSION = '1.5';
20  
21 =head1 SYNOPSIS
22  
23 Quick summary of what the module does.
24  
25 Perhaps a little code snippet.
26  
27 my $foo = new IMDB::Local('imdbDir' => "./imdb-data",
28 'listsDir' => "./imdb-data/lists",
29 'showProgressBar' => 1);
30  
31 for my $type ( $foo->listTypes() ) {
32 if ( $foo->importList($type) != 0 ) {
33 warn("$type import failed, check $foo->{imdbDir}/stage-$type.log");
34 }
35 }
36 ...
37  
38 =head1 EXPORT
39  
40 A list of functions that can be exported. You can delete this section
41 if you don't export anything, such as for a purely object-oriented module.
42  
43 =head1 SUBROUTINES/METHODS
44  
45 =cut
46  
47 # Use Term::ProgressBar if installed.
48 1 ▶use constant Have_bar => eval {
Subroutine BEGIN: called CC=1 SCAR=0.0
49 1 require Term::ProgressBar;
50 1 $Term::ProgressBar::VERSION >= 2;
51 1 };
52  
53 1 ▶use IMDB::Local::DB;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 1 ▶use IMDB::Local::QualifierType ':types';
Subroutine BEGIN: called CC=1 SCAR=0.0
55  
56 =head2 new
57  
58 Create new IMDB::Local object.
59  
60 Arguments:
61  
62 imdbDir - required or die
63  
64 verbose - optional, default is 0.
65  
66 listsDir - folder where list files exist (see IMDB::Local::Download).
67  
68 showProgressBar - if non-zero and Term::ProgressBar is available progress bars in import methods will be displayed. Ignored if Term::ProgressBar is not available.
69  
70 =cut
71  
72 sub new
73 0 ▶{
Subroutine new: not called CC=4 SCAR=30.0
Pod documented
74 0 my ($type) = shift;
75 0 my $self={ @_ }; # remaining args become attributes
76  
77 0 for ('imdbDir', 'verbose') {
78 0 ▶ die "invalid usage - no $_" if ( !defined($self->{$_}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{$_} 0 0 0
79 }
80
81 #$self->{stages} = { 1=>'movies', 2=>'directors', 3=>'actors', 4=>'actresses', 5=>'genres', 6=>'ratings', 7=>'keywords', 8=>'plot' };
82 #$self->{optionalStages} = { 'keywords' => 7, 'plot' => 8 }; # list of optional stages - no need to download files for these
83  
84 0 $self->{moviedbInfo}="$self->{imdbDir}/moviedb.info";
85 0 $self->{moviedbOffline}="$self->{imdbDir}/moviedb.offline";
86
87 0 ▶ if ( defined($self->{listsDir}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"listsDir"}) 0 0 0
88 0 $self->{listFiles}=new IMDB::Local::ListFiles(listsDir=>$self->{listsDir});
89 }
90
91 # only leave progress bar on if its available
92 0 if ( !Have_bar ) {
93 $self->{showProgressBar}=0;
94 }
95  
96 0 bless($self, $type);
97 0 return($self);
98 }
99  
100 #sub openDB
101 #{
102 # my ($self)=@_;
103 #
104 # my $DB=new IMDB::Local::DB(database=>"$self->{imdbDir}/imdb.db");
105 #
106 # if ( !$DB->connect() ) {
107 # carp "imdbdb connect failed:$DBI::errstr";
108 # }
109 # $self->{DB}=$DB;
110 #
111 # return($DB);
112 #}
113 #
114 #sub closeDB
115 #{
116 # my ($self)=@_;
117 #
118 # $self->{DB}->disconnect();
119 # undef $self->{DB};
120 #}
121  
122 =head2 listTypes
123  
124 Returns an array of list files supported (currently 'movies', 'directors', 'actors', 'actresses', 'genres', 'ratings', 'keywords', 'plot')
125  
126 =cut
127  
128 sub listTypes($)
129 0 ▶{
Subroutine listTypes: not called CC=1 SCAR=6.9
Pod documented
130 0 my $self=shift;
131  
132 0 return( $self->{listFiles}->types() );
133 }
134  
135  
136 sub error($$)
137 0 ▶{
Subroutine error: not called CC=2 SCAR=17.9
Pod undocumented
138 0 my $self=shift;
139 0 ▶ if ( defined($self->{logfd}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'logfd'}) { } 0 0 0
140 0 print {$self->{logfd}} $_[0]."\n";
141 0 $self->{errorCountInLog}++;
142 }
143 else {
144 0 print STDERR $_[0]."\n";
145 }
146 }
147  
148 sub status($$)
149 0 ▶{
Subroutine status: not called CC=2 SCAR=17.9
Pod undocumented
150 0 my $self=shift;
151  
152 0 ▶ if ( $self->{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"verbose"}) 0 0 0
153 0 print STDERR $_[0]."\n";
154 }
155 }
156  
157 sub withThousands ($)
158 0 ▶{
Subroutine withThousands: not called CC=1 SCAR=6.9
Pod undocumented
159 0 my ($val) = @_;
160 0 $val =~ s/(\d{1,3}?)(?=(\d{3})+$)/$1,/g;
161 0 return $val;
162 }
163  
164 1 ▶use constant Have_gunzip => eval {
Subroutine BEGIN: called CC=1 SCAR=0.0
165 1 require IO::Uncompress::Gunzip;
166 1 };
167  
168  
169 sub openMaybeGunzip($)
170 0 ▶{
Subroutine openMaybeGunzip: not called CC=2 SCAR=17.9
Pod undocumented
171 0 my ($file)=@_;
172
173 0 ▶ if ($file=~m/\.gz$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /\.gz$/) { } 0 0 0
174 0 if ( Have_gunzip ) {
175 0 return new IO::Uncompress::Gunzip($file);
176 }
177 else {
178 my $fd;
179  
180 if ( open($fd, "gzip -d < $file |") ) {
181 return($fd);
182 }
183 carp("no suitable gzip decompression found");
184 }
185 }
186 else {
187 0 require IO::File;
188 0 return new IO::File("< $file");
189 }
190 }
191  
192 sub closeMaybeGunzip($$)
193 0 ▶{
Subroutine closeMaybeGunzip: not called CC=2 SCAR=17.9
Pod undocumented
194 0 my ($file, $fd)=@_;
195  
196 0 ▶ if ($file=~m/\.gz$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /\.gz$/) { } 0 0 0
197 0 if ( Have_gunzip ) {
198 0 $fd->close();
199 }
200 else {
201 close($fd);
202 }
203 }
204 else {
205 0 $fd->close();
206 }
207 }
208  
209 sub decodeImdbKey($$$)
210 0 ▶{
Subroutine decodeImdbKey: not called CC=25 SCAR=64.8
Pod undocumented
211 0 my ($self, $DB, $dbkey, $year, $titleID)=@_;
212
213 0 my %hash;
214
215 0 $hash{parentId}=0;
216 0 $hash{series}=0;
217 0 $hash{episode}=0;
218 0 $hash{airdate}=0;
219
220  
221 # drop episode information - ex: "Studio One" (1948) {Twelve Angry Men (#7.1)}
222 0 ▶ if ( $dbkey=~s/\s*\{([^\}]+)\}//o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dbkey =~ s/\s*\{([^\}]+)\}//o) 0 0 0
223 0 my $s=$1;
224 0 ▶ if ( $s=~s/\s*\(\#(\d+)\.(\d+)\)$// ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($s =~ s/\s*\(\#(\d+)\.(\d+)\)$//) { } 0 0 0
elsif ($s =~ /^\((\d\d\d\d)\-(\d\d)\-(\d\d)\)$/) { } 0 0 0
225 0 $hash{series}=$1;
226 0 $hash{episode}=$2;
227 0 $hash{title}=$s;
228 #print "title: $s\n";
229  
230 # attempt to locate parentId matching series title
231 #my $parentKey=$dbkey;
232 #$parentKey=~s/^\"//o;
233 #$parentKey=~s/\" \(/ \(/o;
234  
235 #warn("checkskey $dbkey");
236 #if ( defined($self->{seriesKeys}->{$parentKey}) ) {
237 #$hash{parentId}=$self->{seriesKeys}->{$parentKey};
238 #}
239 }
240 # "EastEnders" (1985) {(1991-10-15)} 1991
241 elsif ( $s=~m/^\((\d\d\d\d)\-(\d\d)\-(\d\d)\)$/ ) {
242 0 $hash{airdate}=int("$1$2$3");
243 0 $hash{title}=$s;
244 }
245 else {
246 0 $hash{title}=$s;
247 }
248  
249 # attempt to locate parentId matching series title
250 0 my $parentKey=$dbkey;
251 0 $parentKey=~s/^\"//o;
252 0 $parentKey=~s/\" \(/ \(/o;
253
254 #warn("checkskey $dbkey");
255 0 ▶ if ( defined($self->{seriesKeys}->{$parentKey}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"seriesKeys"}{$parentKey}) 0 0 0
256 0 $hash{parentId}=$self->{seriesKeys}->{$parentKey};
257 }
258 }
259
260
261 # change double-quotes around title to be (made-for-tv) suffix instead
262 0 ▶ if ( $dbkey=~s/^\"//o && $dbkey=~s/\" \(/ \(/o) {
Branch: 4 branches
BranchTrueFalseTotal
if ($dbkey =~ s/^\"//o and $dbkey =~ s/\" \(/ (/o) { } 0 0 0
elsif ($dbkey =~ s/\s+\(TV\)$//o) { } 0 0 0
elsif ($dbkey =~ s/\s+\(V\)$//o) { } 0 0 0
elsif ($dbkey =~ s/\s+\(VG\)$//o) { } 0 0 0
Condition0%0/3
$dbkey =~ s/^\"//o and $dbkey =~ s/\" \(/ (/o
!ll&&!rl&&r
000
MC/DC0%0/2
$dbkey =~ s/^\"//o and $dbkey =~ s/\" \(/ (/o
$dbkey =~ s/^\"//o $dbkey =~ s/\" \(/ (/o
Truth table0%0/3
A and B
A= $dbkey =~ s/^\"//oB= $dbkey =~ s/\" \(/ (/o
ABresult
0X0
100
111
263 0 ▶ if ( $dbkey=~s/\s+\(mini\)$//o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dbkey =~ s/\s+\(mini\)$//o) { } 0 0 0
264 0 ▶ if ( $hash{parentId} == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hash{'parentId'} == 0) { } 0 0 0
265 0 $hash{qualifier}=IMDB::Local::QualifierType::TV_MINI_SERIES;
266 0 $self->{seriesKeys}->{$dbkey}=$titleID;
267 }
268 else {
269 0 $hash{qualifier}=IMDB::Local::QualifierType::EPISODE_OF_TV_MINI_SERIES
270 }
271 }
272 else {
273 0 ▶ if ( $hash{parentId} == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hash{'parentId'} == 0) { } 0 0 0
274 0 $hash{qualifier}=IMDB::Local::QualifierType::TV_SERIES;
275 0 $self->{seriesKeys}->{$dbkey}=$titleID;
276 }
277 else {
278 0 $hash{qualifier}=IMDB::Local::QualifierType::EPISODE_OF_TV_SERIES;
279 }
280 }
281 }
282 elsif ( $dbkey=~s/\s+\(TV\)$//o ) {
283 # how rude, some entries have (TV) appearing more than once.
284 #$dbkey=~s/\s*\(TV\)$//o;
285 0 $hash{qualifier}=IMDB::Local::QualifierType::TV_MOVIE;
286 }
287 elsif ( $dbkey=~s/\s+\(V\)$//o ) {
288 0 $hash{qualifier}=IMDB::Local::QualifierType::VIDEO_MOVIE;
289 }
290 elsif ( $dbkey=~s/\s+\(VG\)$//o ) {
291 0 $hash{qualifier}=IMDB::Local::QualifierType::VIDEO_GAME;
292 }
293 else {
294 0 $hash{qualifier}=IMDB::Local::QualifierType::MOVIE;
295 }
296
297 #if ( $dbkey=~s/\s+\((tv_series|tv_mini_series|tv_movie|video_movie|video_game)\)$//o ) {
298 # $qualifier=$1;
299 #}
300 0 $hash{dbkey}=$dbkey;
301  
302 0 my $title=$dbkey;
303
304 # todo - this is the wrong year for episode titles
305 0 ▶ if ( $title=~m/^\"/o && $title=~m/\"\s*\(/o ) { #"
Branch: 1 branch
BranchTrueFalseTotal
if ($title =~ /^\"/o and $title =~ /\"\s*\(/o) 0 0 0
Condition0%0/3
$title =~ /^\"/o and $title =~ /\"\s*\(/o
!ll&&!rl&&r
000
MC/DC0%0/2
$title =~ /^\"/o and $title =~ /\"\s*\(/o
$title =~ /^\"/o $title =~ /\"\s*\(/o
Truth table0%0/3
A and B
A= $title =~ /^\"/oB= $title =~ /\"\s*\(/o
ABresult
0X0
100
111
306 0 $title=~s/^\"//o; #"
307 0 $title=~s/\"(\s*\()/$1/o; #"
308 }
309
310 0 ▶ if ( $title=~s/\s+\((\d\d\d\d)\)$//o ||
Branch: 2 branches
BranchTrueFalseTotal
if ($title =~ s/\s+\((\d\d\d\d)\)$//o or $title =~ s[\s+\((\d\d\d\d)/[IVXL]+\)$][]o) { } 0 0 0
elsif ($title =~ s/\s+\((\?\?\?\?)\)$//o or $title =~ s[\s+\((\?\?\?\?)/[IVXL]+\)$][]o) { } 0 0 0
Condition0%0/3
$title =~ s/\s+\((\d\d\d\d)\)$//o or $title =~ s[\s+\((\d\d\d\d)/[IVXL]+\)$][]o
l!l&&r!l&&!r
000
MC/DC0%0/2
$title =~ s/\s+\((\d\d\d\d)\)$//o or $title =~ s[\s+\((\d\d\d\d)/[IVXL]+\)$][]o
$title =~ s/\s+\((\d\d\d\d)\)$//o $title =~ s[\s+\((\d\d\d\d)/[IVXL]+\)$][]o
Truth table0%0/3
A or B
A= $title =~ s/\s+\((\d\d\d\d)\)$//oB= $title =~ s[\s+\((\d\d\d\d)/[IVXL]+\)$][]o
ABresult
1X1
011
000
311 $title=~s/\s+\((\d\d\d\d)\/[IVXL]+\)$//o ) {
312 # over-ride with what is given
313 0 ▶ if ( !defined($year) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $year) { } 0 0 0
314 0 $hash{year}=$1;
315 }
316 else {
317 0 $hash{year}=$year;
318 }
319 }
320 ▶ elsif ( $title=~s/\s+\((\?\?\?\?)\)$//o ||
Condition0%0/3
$title =~ s/\s+\((\?\?\?\?)\)$//o or $title =~ s[\s+\((\?\?\?\?)/[IVXL]+\)$][]o
l!l&&r!l&&!r
000
MC/DC0%0/2
$title =~ s/\s+\((\?\?\?\?)\)$//o or $title =~ s[\s+\((\?\?\?\?)/[IVXL]+\)$][]o
$title =~ s/\s+\((\?\?\?\?)\)$//o $title =~ s[\s+\((\?\?\?\?)/[IVXL]+\)$][]o
Truth table0%0/3
A or B
A= $title =~ s/\s+\((\?\?\?\?)\)$//oB= $title =~ s[\s+\((\?\?\?\?)/[IVXL]+\)$][]o
ABresult
1X1
011
000
321 $title=~s/\s+\((\?\?\?\?)\/[IVXL]+\)$//o ) {
322 # over-ride with what is given
323 0 ▶ if ( !defined($year) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $year) { } 0 0 0
324 0 $hash{year}=0;
325 }
326 else {
327 0 $hash{year}=$year;
328 }
329 }
330 else {
331 0 $self->error("movie list format failed to decode year from title '$title'");
332
333 # over-ride with what is given
334 0 ▶ if ( ! defined($year) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $year) { } 0 0 0
335 0 $hash{year}=0;
336 }
337 else {
338 0 $hash{year}=$year;
339 }
340 }
341 0 $title=~s/(.*),\s*(The|A|Une|Las|Les|Los|L\'|Le|La|El|Das|De|Het|Een)$/$2 $1/og;
342  
343 # leave searchtitle empty for tv series'
344 0 ▶ if( $hash{qualifier} == IMDB::Local::QualifierType::EPISODE_OF_TV_SERIES ||
Branch: 1 branch
BranchTrueFalseTotal
if ($hash{'qualifier'} == 13 or $hash{'qualifier'} == 12) { } 0 0 0
Condition0%0/3
$hash{"qualifier"} == 13 or $hash{"qualifier"} == 12
l!l&&r!l&&!r
000
MC/DC0%0/2
$hash{"qualifier"} == 13 or $hash{"qualifier"} == 12
$hash{"qualifier"} == 13 $hash{"qualifier"} == 12
Truth table0%0/3
A or B
A= $hash{"qualifier"} == 13B= $hash{"qualifier"} == 12
ABresult
1X1
011
000
345 $hash{qualifier} == IMDB::Local::QualifierType::EPISODE_OF_TV_MINI_SERIES ) {
346 #$hash{title}=$title;
347 0 $hash{searchTitle}=$DB->makeSearchableTitle($hash{title}, 0);;
348 }
349 else {
350 0 ▶ if ( !defined($hash{title}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $hash{'title'}) { } 0 0 0
351 0 $hash{title}=$title;
352 0 $hash{searchTitle}=$DB->makeSearchableTitle($title, 0);
353  
354 # todo - is this more useful ?
355 #$hash{searchTitleWithYear}=MakeSearchtitle($DB, $title."(".$hash{year}.")", 0);
356 }
357 else {
358 0 $hash{searchTitle}=$DB->makeSearchableTitle($title, 0);
359 #$hash{searchTitle}=$DB->makeSearchableTitle($title."(".$hash{year}.")", 0);
360
361 # todo - is this more useful ?
362 #$hash{searchTitleWithYear}=$DB->makeSearchableTitle($title."(".$hash{year}.")", 0);
363 }
364 }
365  
366 0 return(\%hash);
367 }
368  
369 sub importMovies($$$$)
370 0 ▶{
Subroutine importMovies: not called CC=24 SCAR=64.0
Pod undocumented
371 0 my ($self, $countEstimate, $file, $DB)=@_;
372 0 my $startTime=time();
373 0 my $lineCount=0;
374  
375 0 ▶ my $fh = openMaybeGunzip($file) || return(-2);
Condition0%0/2
&openMaybeGunzip($file) || (return -2)
l!l
00
MC/DC0%0/1
&openMaybeGunzip($file) || (return -2)
&openMaybeGunzip($file)
Truth table0%0/2
A
A= &openMaybeGunzip($file)
Aresult
11
00
376 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
377 0 $lineCount++;
378 0 ▶ if ( m/^MOVIES LIST/o ) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^MOVIES LIST/o) { } 0 0 0
elsif ($lineCount > 1000) { } 0 0 0
379 0 ▶ if ( !($_=<$fh>) || !m/^===========/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^===========/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^===========/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^===========/o
$_ = readline $fh /^===========/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^===========/o
ABresult
0X0
100
111
380 0 $self->error("missing ======= after 'MOVIES LIST' at line $lineCount");
381 0 closeMaybeGunzip($file, $fh);
382 0 return(-1);
383 }
384 0 ▶ if ( !($_=<$fh>) || !m/^\s*$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^\s*$/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^\s*$/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^\s*$/o
$_ = readline $fh /^\s*$/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^\s*$/o
ABresult
0X0
100
111
385 0 $self->error("missing empty line after ======= at line $lineCount");
386 0 closeMaybeGunzip($file, $fh);
387 0 return(-1);
388 }
389 0 last;
390 }
391 elsif ( $lineCount > 1000 ) {
392 0 $self->error("$file: stopping at line $lineCount, didn't see \"MOVIES LIST\" line");
393 0 closeMaybeGunzip($file, $fh);
394 0 return(-1);
395 }
396 }
397  
398 my $progress=Term::ProgressBar->new({name => "importing Movies",
399 count => $countEstimate,
400 ETA => 'linear'})
401 0 ▶ if ( $self->{showProgressBar} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
402  
403 0 ▶ $progress->minor(0) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
404 0 ▶ $progress->max_update_rate(1) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
405 0 my $next_update=0;
406  
407 #$DB->runSQL("BEGIN TRANSACTION");
408  
409 0 my $count=0;
410 0 my $tableInsert_sth=$DB->prepare('INSERT INTO Titles (TitleID, SearchTitle, Title, QualifierTypeID, Year, ParentID, Series, Episode, AirDate) VALUES (?,?,?,?,?,?,?,?,?)');
411  
412 0 my $potentialEntries=0;
413
414 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
415 0 $lineCount++;
416 0 my $line=$_;
417  
418 # end is line consisting of only '-'
419 0 ▶ last if ( $line=~m/^\-\-\-\-\-\-\-+/o );
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\-\-\-\-\-\-\-+/o 0 0 0
420  
421 0 ▶ next if ( $line=~m/\{\{SUSPENDED\}\}/o );
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /\{\{SUSPENDED\}\}/o 0 0 0
422 0 $line=~s/\n$//o;
423
424 #next if ( !($line=~m/biography/io) );
425  
426 #print "read line $lineCount:$line\n";
427 0 $potentialEntries++;
428  
429 0 my $tab=index($line, "\t");
430 0 ▶ if ( $tab != -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tab != -1) { } 0 0 0
431 0 my $ykey=substr($line, $tab+1);
432 0 ▶ if ( $ykey=m/\s+(\d\d\d\d)$/ ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($ykey = /\s+(\d\d\d\d)$/) { } 0 0 0
elsif ($ykey = /\s+(\?\?\?\?)$/) { } 0 0 0
elsif ($ykey = /\s+(\d\d\d\d)\-(\?\?\?\?)$/) { } 0 0 0
elsif ($ykey = /\s+(\d\d\d\d)\-(\d\d\d\d)$/) { } 0 0 0
433 0 $ykey=$1;
434 }
435 elsif ( $ykey=m/\s+(\?\?\?\?)$/ ) {
436 0 $ykey=undef;
437 }
438 elsif ( $ykey=m/\s+(\d\d\d\d)\-(\?\?\?\?)$/ ) {
439 0 $ykey=$1;
440 }
441 elsif ( $ykey=m/\s+(\d\d\d\d)\-(\d\d\d\d)$/ ) {
442 0 $ykey=$1;
443 }
444 else {
445 0 warn("invalid year ($ykey) - $line");
446 #$ykey=undef;
447 }
448
449 0 my $mkey=substr($line, 0, $tab);
450  
451 # returned count is number of titles found
452 0 $count++;
453  
454 0 my $decoded=$self->decodeImdbKey($DB, $mkey, $ykey, $count);
455  
456 $tableInsert_sth->execute($count,
457 $decoded->{searchTitle},
458 $decoded->{title},
459 $decoded->{qualifier},
460 $decoded->{year},
461 $decoded->{parentId},
462 $decoded->{series},
463 $decoded->{episode},
464 0 $decoded->{airdate});
465
466 0 $self->{imdbMovie2DBKey}->{$mkey}=$count;
467  
468 #if ( ($count % 50000) == 0 ) {
469 #$DB->commit();
470 #}
471 #}
472
473 0 ▶ if ( $self->{showProgressBar} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"showProgressBar"}) 0 0 0
474 # re-adjust target so progress bar doesn't seem too wonky
475 0 ▶ if ( $count > $countEstimate ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($count > $countEstimate) { } 0 0 0
elsif ($count > $next_update) { } 0 0 0
476 0 $countEstimate = $progress->target($count+1000);
477 0 $next_update=$progress->update($count);
478 }
479 elsif ( $count > $next_update ) {
480 0 $next_update=$progress->update($count);
481 }
482 }
483 }
484 else {
485 0 $self->error("$file:$lineCount: unrecognized format (missing tab)");
486 }
487 }
488 #$DB->runSQL("END TRANSACTION");
489  
490 0 ▶ $progress->update($countEstimate) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
491  
492 0 $self->status(sprintf("importing Movies found ".withThousands($count)." in ".
493 withThousands($potentialEntries)." entries in %d seconds",time()-$startTime));
494  
495 0 closeMaybeGunzip($file, $fh);
496 0 $DB->commit();
497 0 return($count);
498 }
499  
500 sub importGenres($$$$)
501 0 ▶{
Subroutine importGenres: not called CC=23 SCAR=63.1
Pod undocumented
502 0 my ($self, $countEstimate, $file, $DB)=@_;
503 0 my $startTime=time();
504 0 my $lineCount=0;
505  
506 0 ▶ my $fh = openMaybeGunzip($file) || return(-2);
Condition0%0/2
&openMaybeGunzip($file) || (return -2)
l!l
00
MC/DC0%0/1
&openMaybeGunzip($file) || (return -2)
&openMaybeGunzip($file)
Truth table0%0/2
A
A= &openMaybeGunzip($file)
Aresult
11
00
507 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
508 0 $lineCount++;
509 0 ▶ if ( m/^8: THE GENRES LIST/o ) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^8: THE GENRES LIST/o) { } 0 0 0
elsif ($lineCount > 1000) { } 0 0 0
510 0 ▶ if ( !($_=<$fh>) || !m/^===========/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^===========/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^===========/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^===========/o
$_ = readline $fh /^===========/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^===========/o
ABresult
0X0
100
111
511 0 $self->error("missing ======= after 'THE GENRES LIST' at line $lineCount");
512 0 closeMaybeGunzip($file, $fh);
513 0 return(-1);
514 }
515 0 ▶ if ( !($_=<$fh>) || !m/^\s*$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^\s*$/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^\s*$/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^\s*$/o
$_ = readline $fh /^\s*$/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^\s*$/o
ABresult
0X0
100
111
516 0 $self->error("missing empty line after ======= at line $lineCount");
517 0 closeMaybeGunzip($file, $fh);
518 0 return(-1);
519 }
520 0 last;
521 }
522 elsif ( $lineCount > 1000 ) {
523 0 $self->error("$file: stopping at line $lineCount, didn't see \"THE GENRES LIST\" line");
524 0 closeMaybeGunzip($file, $fh);
525 0 return(-1);
526 }
527 }
528  
529 my $progress=Term::ProgressBar->new({name => "importing Genres",
530 count => $countEstimate,
531 ETA => 'linear'})
532 0 ▶ if ( $self->{showProgressBar} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
533  
534 0 ▶ $progress->minor(0) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
535 0 ▶ $progress->max_update_rate(1) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
536 0 my $next_update=0;
537  
538 #$DB->runSQL("BEGIN TRANSACTION");
539  
540 0 my $count=0;
541 0 my $potentialEntries=0;
542 0 my $tableInsert_sth=$DB->prepare('INSERT INTO Titles2Genres (TitleID, GenreID) VALUES (?,?)');
543  
544 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
545 0 $lineCount++;
546 0 my $line=$_;
547 #print "read line $lineCount:$line\n";
548  
549 # end is line consisting of only '-'
550 0 ▶ last if ( $line=~m/^\-\-\-\-\-\-\-+/o );
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\-\-\-\-\-\-\-+/o 0 0 0
551 0 ▶ next if ( $line=~m/\s*\{\{SUSPENDED\}\}/o);
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /\s*\{\{SUSPENDED\}\}/o 0 0 0
552  
553 0 $potentialEntries++;
554  
555 0 $line=~s/\n$//o;
556  
557 0 my $tab=index($line, "\t");
558 0 ▶ if ( $tab != -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tab != -1) { } 0 0 0
559 0 my $mkey=substr($line, 0, $tab);
560  
561 # ignore {Twelve Angry Men (1954)}
562 # TODO - do we want this ?
563 #$mkey=~s/\s*\{[^\}]+\}//go;
564
565 # skip enties that have {} in them since they're tv episodes
566 #next if ( $mkey=~s/\s*\{[^\}]+\}$//o );
567
568 0 my $genre=substr($line, $tab);
569
570 # genres sometimes has more than one tab
571 0 $genre=~s/^\t+//og;
572
573 0 ▶ if ( $self->{imdbMovie2DBKey}->{$mkey} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"imdbMovie2DBKey"}{$mkey}) 0 0 0
574 # insert into db as discovered
575 0 ▶ if ( ! defined($self->{GenreID}->{$genre}) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"GenreID"}{$genre}) 0 0 0
576 0 $self->{GenreID}->{$genre}=$DB->insert_row('Genres', 'GenreID', Name=>$genre);
577 }
578 $tableInsert_sth->execute($self->{imdbMovie2DBKey}->{$mkey},
579 0 $self->{GenreID}->{$genre});
580
581 # returned count is number of titles found
582 0 $count++;
583
584 0 ▶ if ( ($count % 50000) ==0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count % 50000 == 0) 0 0 0
585 0 $DB->commit();
586 }
587 }
588
589 0 ▶ if ( $self->{showProgressBar} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"showProgressBar"}) 0 0 0
590 # re-adjust target so progress bar doesn't seem too wonky
591 0 ▶ if ( $count > $countEstimate ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($count > $countEstimate) { } 0 0 0
elsif ($count > $next_update) { } 0 0 0
592 0 $countEstimate = $progress->target($count+1000);
593 0 $next_update=$progress->update($count);
594 }
595 elsif ( $count > $next_update ) {
596 0 $next_update=$progress->update($count);
597 }
598 }
599 }
600 else {
601 0 $self->error("$file:$lineCount: unrecognized format (missing tab)");
602 }
603 }
604 #$DB->runSQL("END TRANSACTION");
605  
606 0 ▶ $progress->update($countEstimate) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
607  
608 0 $self->status(sprintf("importing Genres found ".withThousands($count)." in ".
609 withThousands($potentialEntries)." entries in %d seconds",time()-$startTime));
610  
611 0 closeMaybeGunzip($file, $fh);
612 0 $DB->commit();
613 0 return($count);
614 }
615  
616 sub importActors($$$$)
617 0 ▶{
Subroutine importActors: not called CC=47 SCAR=77.2
Pod undocumented
618 0 my ($self, $whichCastType, $castCountEstimate, $file, $DB)=@_;
619 0 my $startTime=time();
620  
621 0 ▶ if ( $whichCastType eq "Actors" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($whichCastType eq "Actors") 0 0 0
622 0 ▶ if ( $DB->table_row_count('Actors') > 0 ||
Branch: 1 branch
BranchTrueFalseTotal
if ($DB->table_row_count("Actors") > 0 or $DB->table_row_count("Titles2Actors") > 0 or $DB->table_row_count("Titles2Hosts") > 0 or $DB->table_row_count("Titles2Narrators") > 0) 0 0 0
Condition0%0/9
$DB->table_row_count("Actors") > 0 or $DB->table_row_count("Titles2Actors") > 0 or $DB->table_row_count("Titles2Hosts") > 0 or $DB->table_row_count("Titles2Narrators") > 0
l!l&&r!l&&!r
000
$DB->table_row_count("Actors") > 0 or $DB->table_row_count("Titles2Actors") > 0 or $DB->table_row_count("Titles2Hosts") > 0
l!l&&r!l&&!r
000
$DB->table_row_count("Actors") > 0 or $DB->table_row_count("Titles2Actors") > 0
l!l&&r!l&&!r
000
MC/DC0%0/4
$DB->table_row_count("Actors") > 0 or $DB->table_row_count("Titles2Actors") > 0 or $DB->table_row_count("Titles2Hosts") > 0 or $DB->table_row_count("Titles2Narrators") > 0
$DB->table_row_count("Actors") > 0 $DB->table_row_count("Titles2Actors") > 0 $DB->table_row_count("Titles2Hosts") > 0 $DB->table_row_count("Titles2Narrators") > 0
Truth table0%0/5
A or B or C or D
A= $DB->table_row_count("Actors") > 0B= $DB->table_row_count("Titles2Actors") > 0C= $DB->table_row_count("Titles2Hosts") > 0D= $DB->table_row_count("Titles2Narrators") > 0
ABCDresult
1XXX1
01XX1
001X1
00011
00000
623 $DB->table_row_count('Titles2Actors') > 0 ||
624 $DB->table_row_count('Titles2Hosts') > 0 ||
625 $DB->table_row_count('Titles2Narrators') > 0 ) {
626 0 $self->status("clearing previously loaded data..");
627 0 $DB->table_clear('Actors');
628 0 $DB->table_clear('Titles2Actors');
629 0 $DB->table_clear('Titles2Hosts');
630 0 $DB->table_clear('Titles2Narrators');
631 }
632 }
633  
634 0 my $header;
635 my $whatAreWeParsing;
636 0 my $lineCount=0;
637  
638 0 ▶ if ( $whichCastType eq "Actors" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($whichCastType eq 'Actors') { } 0 0 0
elsif ($whichCastType eq 'Actresses') { } 0 0 0
639 0 $header="THE ACTORS LIST";
640 0 $whatAreWeParsing=1;
641 }
642 elsif ( $whichCastType eq "Actresses" ) {
643 0 $header="THE ACTRESSES LIST";
644 0 $whatAreWeParsing=2;
645 }
646 else {
647 0 die "why are we here ?";
648 }
649  
650 0 ▶ my $fh = openMaybeGunzip($file) || return(-2);
Condition0%0/2
&openMaybeGunzip($file) || (return -2)
l!l
00
MC/DC0%0/1
&openMaybeGunzip($file) || (return -2)
&openMaybeGunzip($file)
Truth table0%0/2
A
A= &openMaybeGunzip($file)
Aresult
11
00
651 my $progress=Term::ProgressBar->new({name => "importing $whichCastType",
652 count => $castCountEstimate,
653 ETA => 'linear'})
654 0 ▶ if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
655 0 ▶ $progress->minor(0) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
656 0 ▶ $progress->max_update_rate(1) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
657 0 my $next_update=0;
658
659 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
660 0 $lineCount++;
661 0 ▶ if ( m/^$header/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^$header/) { } 0 0 0
elsif ($lineCount > 1000) { } 0 0 0
662 0 ▶ if ( !($_=<$fh>) || !m/^===========/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^===========/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^===========/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^===========/o
$_ = readline $fh /^===========/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^===========/o
ABresult
0X0
100
111
663 0 $self->error("missing ======= after $header at line $lineCount");
664 0 closeMaybeGunzip($file, $fh);
665 0 return(-1);
666 }
667 0 ▶ if ( !($_=<$fh>) || !m/^\s*$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^\s*$/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^\s*$/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^\s*$/o
$_ = readline $fh /^\s*$/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^\s*$/o
ABresult
0X0
100
111
668 0 $self->error("missing empty line after ======= at line $lineCount");
669 0 closeMaybeGunzip($file, $fh);
670 0 return(-1);
671 }
672 0 ▶ if ( !($_=<$fh>) || !m/^Name\s+Titles\s*$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^Name\s+Titles\s*$/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^Name\s+Titles\s*$/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^Name\s+Titles\s*$/o
$_ = readline $fh /^Name\s+Titles\s*$/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^Name\s+Titles\s*$/o
ABresult
0X0
100
111
673 0 $self->error("missing name/titles line after ======= at line $lineCount");
674 0 closeMaybeGunzip($file, $fh);
675 0 return(-1);
676 }
677 0 ▶ if ( !($_=<$fh>) || !m/^[\s\-]+$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^[\s\-]+$/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^[\s\-]+$/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^[\s\-]+$/o
$_ = readline $fh /^[\s\-]+$/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^[\s\-]+$/o
ABresult
0X0
100
111
678 0 $self->error("missing name/titles suffix line after ======= at line $lineCount");
679 0 closeMaybeGunzip($file, $fh);
680 0 return(-1);
681 }
682 0 last;
683 }
684 elsif ( $lineCount > 1000 ) {
685 0 $self->error("$file: stopping at line $lineCount, didn't see \"$header\" line");
686 0 closeMaybeGunzip($file, $fh);
687 0 return(-1);
688 }
689 }
690  
691 0 my $cur_name;
692 0 my $count=0;
693 0 my $castNames=0;
694 0 my $tableInsert_sth1=$DB->prepare('INSERT INTO Actors (ActorID, SearchName, Name) VALUES (?,?,?)');
695 0 my $tableInsert_sth2=$DB->prepare('INSERT INTO Titles2Hosts (TitleID, ActorID) VALUES (?,?)');
696 0 my $tableInsert_sth3=$DB->prepare('INSERT INTO Titles2Narrators (TitleID, ActorID) VALUES (?,?)');
697 0 my $tableInsert_sth4=$DB->prepare('INSERT INTO Titles2Actors (TitleID, ActorID, Billing) VALUES (?,?,?)');
698
699 0 my $cur_actorId=$DB->select2Scalar('Select MAX(ActorID) from Actors');
700 0 ▶ if ( !defined($cur_actorId) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $cur_actorId) 0 0 0
701 0 $cur_actorId=0;
702 }
703  
704 0 my $potentialEntries=0;
705 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
706 0 $lineCount++;
707 0 my $line=$_;
708 0 $line=~s/\n$//o;
709 #$self->status("read line $lineCount:$line");
710  
711 # end is line consisting of only '-'
712 0 ▶ last if ( $line=~m/^\-\-\-\-\-\-\-+/o );
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\-\-\-\-\-\-\-+/o 0 0 0
713
714 0 ▶ next if ( length($line) == 0 );
Branch: 1 branch
BranchTrueFalseTotal
if length $line == 0 0 0 0
715  
716 # try ignoring these
717 0 ▶ next if ($line=~m/\s*\{\{SUSPENDED\}\}/o);
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /\s*\{\{SUSPENDED\}\}/o 0 0 0
718  
719 0 $potentialEntries++;
720 0 my $billing=9999;
721
722 # actors or actresses
723 0 ▶ if ( $line=~s/\s*<(\d+)>//o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ s/\s*<(\d+)>//o) 0 0 0
724 0 $billing=int($1);
725 0 ▶ next if ( $billing >3 );
Branch: 1 branch
BranchTrueFalseTotal
if $billing > 3 0 0 0
726 }
727
728 0 ▶ if ( $line=~s/^([^\t]+)\t+//o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ s/^([^\t]+)\t+//o) 0 0 0
729 0 $cur_name=$1;
730 0 $castNames++;
731  
732 0 $cur_actorId++;
733  
734 0 my $c=$cur_name;
735 0 $c=~s/\s*\([IVXL]+\)//o;
736 0 $tableInsert_sth1->execute($cur_actorId, $DB->makeSearchableTitle($c, 0), $cur_name);
737  
738 0 ▶ if ( $self->{showProgressBar} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"showProgressBar"}) 0 0 0
739 # re-adjust target so progress bar doesn't seem too wonky
740 0 ▶ if ( $castNames > $castCountEstimate ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($castNames > $castCountEstimate) { } 0 0 0
elsif ($castNames > $next_update) { } 0 0 0
741 0 $castCountEstimate = $progress->target($castNames+100);
742 0 $next_update=$progress->update($castNames);
743 }
744 elsif ( $castNames > $next_update ) {
745 0 $next_update=$progress->update($castNames);
746 }
747 }
748 }
749
750 0 my $isHost=0;
751 0 my $isNarrator=0;
752 0 ▶ if ( (my $start=index($line, " [")) != -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((my $start = index($line, " [")) != -1) 0 0 0
753 #my $end=rindex($line, "]");
754 0 my $ex=substr($line, $start+1);
755
756 0 ▶ if ( $ex=~s/Host//o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ex =~ s/Host//o) 0 0 0
757 0 $isHost=1;
758 }
759 0 ▶ if ( $ex=~s/Narrator//o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ex =~ s/Narrator//o) 0 0 0
760 0 $isNarrator=1;
761 }
762 0 $line=substr($line, 0, $start);
763 # ignore character name
764 }
765
766 # TODO - do we want to just ignore these ?
767 0 ▶ if ( $line=~s/\s*\(aka ([^\)]+)\).*$//o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ s/\s*\(aka ([^\)]+)\).*$//o) 0 0 0
768 #$attrs=$1;
769 }
770
771 # TODO - what are we ignoring here ?
772 0 ▶ if ( $line=~s/ (\(.*)$//o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ s/ (\(.*)$//o) 0 0 0
773 #$attrs=$1;
774 }
775 0 $line=~s/^\s+//og;
776 0 $line=~s/\s+$//og;
777  
778 # TODO - does this exist ?
779 0 ▶ if ( $line=~s/\s+Narrator$//o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ s/\s+Narrator$//o) 0 0 0
780 0 $self->error("extra narrator on line: $lineCount");
781 # TODO - do we want to store this ? Does it actually occur ?
782 # ignore
783 }
784  
785 #if ( $line=~s/\s*\([A-Z]+\)$//o ) {
786 #}
787  
788 0 my $titleID=$self->{imdbMovie2DBKey}->{$line};
789 0 ▶ if ( $titleID ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($titleID) { } 0 0 0
790 0 ▶ if ( $isHost ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isHost) 0 0 0
791 0 $tableInsert_sth2->execute($titleID, $cur_actorId);
792 }
793 0 ▶ if ( $isNarrator ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isNarrator) 0 0 0
794 0 $tableInsert_sth3->execute($titleID, $cur_actorId);
795 }
796 0 ▶ if ( !$isHost && !$isNarrator ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($isHost or $isNarrator) 0 0 0
Condition0%0/3
$isHost or $isNarrator
l!l&&r!l&&!r
000
MC/DC0%0/2
$isHost or $isNarrator
$isHost $isNarrator
Truth table0%0/3
A or B
A= $isHostB= $isNarrator
ABresult
1X1
011
000
797 0 $tableInsert_sth4->execute($titleID, $cur_actorId, $billing);
798 }
799
800 0 $count++;
801 0 ▶ if ( ($count % 50000) == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count % 50000 == 0) 0 0 0
802 0 $DB->commit();
803 }
804 }
805 else {
806 #warn($line);
807 }
808 }
809 0 ▶ $progress->update($castCountEstimate) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
810  
811 0 $self->status(sprintf("importing $whichCastType found ".withThousands($castNames)." names, ".
812 withThousands($count)." titles in ".withThousands($potentialEntries)." entries in %d seconds",time()-$startTime));
813
814 0 closeMaybeGunzip($file, $fh);
815  
816 0 $DB->commit();
817 0 return($castNames);
818 }
819  
820 sub importDirectors($$$)
821 0 ▶{
Subroutine importDirectors: not called CC=31 SCAR=69.0
Pod undocumented
822 0 my ($self, $castCountEstimate, $file, $DB)=@_;
823 0 my $startTime=time();
824  
825 0 my $lineCount=0;
826  
827 0 ▶ if ( $DB->table_row_count('Directors') > 0 ||
Branch: 1 branch
BranchTrueFalseTotal
if ($DB->table_row_count("Directors") > 0 or $DB->table_row_count("Titles2Directors") > 0) 0 0 0
Condition0%0/3
$DB->table_row_count("Directors") > 0 or $DB->table_row_count("Titles2Directors") > 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$DB->table_row_count("Directors") > 0 or $DB->table_row_count("Titles2Directors") > 0
$DB->table_row_count("Directors") > 0 $DB->table_row_count("Titles2Directors") > 0
Truth table0%0/3
A or B
A= $DB->table_row_count("Directors") > 0B= $DB->table_row_count("Titles2Directors") > 0
ABresult
1X1
011
000
828 $DB->table_row_count('Titles2Directors') > 0 ) {
829 0 $self->status("clearing previously loaded data..");
830 0 $DB->table_clear('Directors');
831 0 $DB->table_clear('Titles2Directors');
832 }
833  
834 0 ▶ my $fh = openMaybeGunzip($file) || return(-2);
Condition0%0/2
&openMaybeGunzip($file) || (return -2)
l!l
00
MC/DC0%0/1
&openMaybeGunzip($file) || (return -2)
&openMaybeGunzip($file)
Truth table0%0/2
A
A= &openMaybeGunzip($file)
Aresult
11
00
835 my $progress=Term::ProgressBar->new({name => "importing Directors",
836 count => $castCountEstimate,
837 ETA => 'linear'})
838 0 ▶ if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
839 0 ▶ $progress->minor(0) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
840 0 ▶ $progress->max_update_rate(1) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
841 0 my $next_update=0;
842 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
843 0 $lineCount++;
844 0 ▶ if ( m/^THE DIRECTORS LIST/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^THE DIRECTORS LIST/) { } 0 0 0
elsif ($lineCount > 1000) { } 0 0 0
845 0 ▶ if ( !($_=<$fh>) || !m/^===========/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^===========/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^===========/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^===========/o
$_ = readline $fh /^===========/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^===========/o
ABresult
0X0
100
111
846 0 $self->error("missing ======= after THE DIRECTORS LIST at line $lineCount");
847 0 closeMaybeGunzip($file, $fh);
848 0 return(-1);
849 }
850 0 ▶ if ( !($_=<$fh>) || !m/^\s*$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^\s*$/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^\s*$/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^\s*$/o
$_ = readline $fh /^\s*$/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^\s*$/o
ABresult
0X0
100
111
851 0 $self->error("missing empty line after ======= at line $lineCount");
852 0 closeMaybeGunzip($file, $fh);
853 0 return(-1);
854 }
855 0 ▶ if ( !($_=<$fh>) || !m/^Name\s+Titles\s*$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^Name\s+Titles\s*$/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^Name\s+Titles\s*$/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^Name\s+Titles\s*$/o
$_ = readline $fh /^Name\s+Titles\s*$/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^Name\s+Titles\s*$/o
ABresult
0X0
100
111
856 0 $self->error("missing name/titles line after ======= at line $lineCount");
857 0 closeMaybeGunzip($file, $fh);
858 0 return(-1);
859 }
860 0 ▶ if ( !($_=<$fh>) || !m/^[\s\-]+$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^[\s\-]+$/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^[\s\-]+$/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^[\s\-]+$/o
$_ = readline $fh /^[\s\-]+$/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^[\s\-]+$/o
ABresult
0X0
100
111
861 0 $self->error("missing name/titles suffix line after ======= at line $lineCount");
862 0 closeMaybeGunzip($file, $fh);
863 0 return(-1);
864 }
865 0 last;
866 }
867 elsif ( $lineCount > 1000 ) {
868 0 $self->error("$file: stopping at line $lineCount, didn't see \"THE DIRECTORS LIST\" line");
869 0 closeMaybeGunzip($file, $fh);
870 0 return(-1);
871 }
872 }
873  
874 0 my $cur_name;
875 0 my $count=0;
876 0 my $castNames=0;
877 0 my %found;
878 0 my $directorCount=0;
879 0 my $potentialEntries=0;
880  
881 0 my $tableInsert_sth=$DB->prepare('INSERT INTO Directors (DirectorID, SearchName, Name) VALUES (?,?,?)');
882 0 my $tableInsert_sth2=$DB->prepare('INSERT INTO Titles2Directors (TitleID, DirectorID) VALUES (?,?)');
883 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
884 0 $lineCount++;
885
886 #last if ( $lineCount > 10000);
887 0 my $line=$_;
888 0 $line=~s/\n$//o;
889 #$self->status("read line $lineCount:$line");
890  
891 # end is line consisting of only '-'
892 0 ▶ last if ( $line=~m/^\-\-\-\-\-\-\-+/o );
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\-\-\-\-\-\-\-+/o 0 0 0
893 0 ▶ next if ( length($line) == 0 );
Branch: 1 branch
BranchTrueFalseTotal
if length $line == 0 0 0 0
894
895 # try ignoring these
896 0 ▶ next if ($line=~m/\s*\{\{SUSPENDED\}\}/o);
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /\s*\{\{SUSPENDED\}\}/o 0 0 0
897
898 0 $potentialEntries++;
899
900 0 ▶ if ( $line=~s/^([^\t]+)\t+//o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ s/^([^\t]+)\t+//o) 0 0 0
901 0 $cur_name=$1;
902 0 $castNames++;
903  
904 0 ▶ if ( $self->{showProgressBar} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"showProgressBar"}) 0 0 0
905 # re-adjust target so progress bar doesn't seem too wonky
906 0 ▶ if ( $castNames > $castCountEstimate ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($castNames > $castCountEstimate) { } 0 0 0
elsif ($castNames > $next_update) { } 0 0 0
907 0 $castCountEstimate = $progress->target($castNames+100);
908 0 $next_update=$progress->update($castNames);
909 }
910 elsif ( $castNames > $next_update ) {
911 0 $next_update=$progress->update($castNames);
912 }
913 }
914 }
915
916 # BUG
917 # ##ignore {Twelve Angry Men (1954)}
918 #$line=~s/\s*\{[^\}]+\}//o;
919  
920 # sometimes there are extra bits of info attached at the end of lines, we'll ignore these
921 #
922 # examples:
923 # Deszcz (1997) (as Tomasz Baginski)
924 # Adventures of Modest Mouse (2008) (co-director)
925 # Vida (2010) (collaborating director)
926 # Rex Harrison Presents Stories of Love (1974) (TV) (segment "Epicac")
927 0 ▶ if ( $line=~s/ (\(.*)$//o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ s/ (\(.*)$//o) 0 0 0
928 # $attrs=$1;
929 }
930
931 0 $line=~s/^\s+//og;
932 0 $line=~s/\s+$//og;
933  
934 0 ▶ if ( $self->{imdbMovie2DBKey}->{$line} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'imdbMovie2DBKey'}{$line}) { } 0 0 0
935  
936 0 ▶ if ( !defined($found{$cur_name}) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $found{$cur_name}) 0 0 0
937 0 $directorCount++;
938 0 $found{$cur_name}=$directorCount;
939  
940 0 my $c=$cur_name;
941 0 $c=~s/\s*\([IVXL]+\)//o;
942 0 $tableInsert_sth->execute($directorCount, $DB->makeSearchableTitle($c, 0), $cur_name);
943 }
944  
945 0 $tableInsert_sth2->execute($self->{imdbMovie2DBKey}->{$line}, $found{$cur_name});
946 0 $count++;
947 0 ▶ if ( ($count % 50000) == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count % 50000 == 0) 0 0 0
948 0 $DB->commit();
949 }
950 }
951 else {
952 0 $self->error("$lineCount: unable to match title key '$line'");
953 }
954 }
955 0 ▶ $progress->update($castCountEstimate) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
956  
957 0 $self->status(sprintf("importing Directors found ".withThousands($castNames)." names, ".
958 withThousands($count)." titles in ".withThousands($potentialEntries)." entries in %d seconds",time()-$startTime));
959
960 0 closeMaybeGunzip($file, $fh);
961  
962 0 $DB->commit();
963 0 return($castNames);
964 }
965  
966 sub importRatings($$)
967 0 ▶{
Subroutine importRatings: not called CC=23 SCAR=63.1
Pod undocumented
968 0 my ($self, $countEstimate, $file, $DB)=@_;
969 0 my $startTime=time();
970 0 my $lineCount=0;
971  
972 0 ▶ if ( $DB->table_row_count('Ratings') > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($DB->table_row_count("Ratings") > 0) 0 0 0
973 0 $self->status("clearing previously loaded data..");
974 0 $DB->table_clear('Ratings');
975 }
976  
977 0 ▶ my $fh = openMaybeGunzip($file) || return(-2);
Condition0%0/2
&openMaybeGunzip($file) || (return -2)
l!l
00
MC/DC0%0/1
&openMaybeGunzip($file) || (return -2)
&openMaybeGunzip($file)
Truth table0%0/2
A
A= &openMaybeGunzip($file)
Aresult
11
00
978 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
979 0 $lineCount++;
980 0 ▶ if ( m/^MOVIE RATINGS REPORT/o ) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^MOVIE RATINGS REPORT/o) { } 0 0 0
elsif ($lineCount > 1000) { } 0 0 0
981 0 ▶ if ( !($_=<$fh>) || !m/^\s*$/o) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^\s*$/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^\s*$/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^\s*$/o
$_ = readline $fh /^\s*$/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^\s*$/o
ABresult
0X0
100
111
982 0 $self->error("missing empty line after \"MOVIE RATINGS REPORT\" at line $lineCount");
983 0 closeMaybeGunzip($file, $fh);
984 0 return(-1);
985 }
986 0 ▶ if ( !($_=<$fh>) || !m/^New Distribution Votes Rank Title/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^New Distribution Votes Rank Title/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^New Distribution Votes Rank Title/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^New Distribution Votes Rank Title/o
$_ = readline $fh /^New Distribution Votes Rank Title/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^New Distribution Votes Rank Title/o
ABresult
0X0
100
111
987 0 $self->error("missing \"New Distribution Votes Rank Title\" at line $lineCount");
988 0 closeMaybeGunzip($file, $fh);
989 0 return(-1);
990 }
991 0 last;
992 }
993 elsif ( $lineCount > 1000 ) {
994 0 $self->error("$file: stopping at line $lineCount, didn't see \"MOVIE RATINGS REPORT\" line");
995 0 closeMaybeGunzip($file, $fh);
996 0 return(-1);
997 }
998 }
999  
1000 my $progress=Term::ProgressBar->new({name => "importing Ratings",
1001 count => $countEstimate,
1002 ETA => 'linear'})
1003 0 ▶ if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
1004  
1005 0 ▶ $progress->minor(0) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
1006 0 ▶ $progress->max_update_rate(1) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
1007 0 my $next_update=0;
1008  
1009 0 my $countImported=0;
1010 0 my $count=0;
1011 0 my $potentialEntries=0;
1012 0 my $tableInsert_sth=$DB->prepare('INSERT INTO Ratings (TitleID, Distribution, Votes, Rank) VALUES (?,?,?,?)');
1013 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
1014 0 $lineCount++;
1015 0 my $line=$_;
1016 #print "read line $lineCount:$line";
1017  
1018 0 $line=~s/\n$//o;
1019
1020 # skip empty lines (only really appear right before last line ending with ----
1021 0 ▶ next if ( $line=~m/^\s*$/o );
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\s*$/o 0 0 0
1022 # end is line consisting of only '-'
1023 0 ▶ last if ( $line=~m/^\-\-\-\-\-\-\-+/o );
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\-\-\-\-\-\-\-+/o 0 0 0
1024  
1025 0 $potentialEntries++;
1026
1027 # e.g. New Distribution Votes Rank Title
1028 # 0000000133 225568 8.9 12 Angry Men (1957)
1029 0 ▶ if ( $line=~m/^\s+([\.|\*|\d]+)\s+(\d+)\s+(\d+\.\d+)\s+(.+)$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s+([\.|\*|\d]+)\s+(\d+)\s+(\d+\.\d+)\s+(.+)$/o) { } 0 0 0
1030  
1031 0 ▶ if ( $self->{imdbMovie2DBKey}->{$4} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"imdbMovie2DBKey"}{$4}) 0 0 0
1032 0 $tableInsert_sth->execute($self->{imdbMovie2DBKey}->{$4}, $1, $2, $3);
1033 0 $countImported++;
1034 0 ▶ if ( ($countImported % 50000) == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($countImported % 50000 == 0) 0 0 0
1035 0 $DB->commit();
1036 }
1037 }
1038
1039 0 $count++;
1040  
1041 #$self->{movies}{$line}=[$1,$2,"$3.$4"];
1042 0 ▶ if ( $self->{showProgressBar} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"showProgressBar"}) 0 0 0
1043 # re-adjust target so progress bar doesn't seem too wonky
1044 0 ▶ if ( $count > $countEstimate ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($count > $countEstimate) { } 0 0 0
elsif ($count > $next_update) { } 0 0 0
1045 0 $countEstimate = $progress->target($count+1000);
1046 0 $next_update=$progress->update($count);
1047 }
1048 elsif ( $count > $next_update ) {
1049 0 $next_update=$progress->update($count);
1050 }
1051 }
1052 }
1053 else {
1054 0 $self->error("$file:$lineCount: unrecognized format");
1055 }
1056 }
1057 0 ▶ $progress->update($countEstimate) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
1058  
1059 0 $self->status(sprintf("importing Ratings found ".withThousands($count)." in ".
1060 withThousands($potentialEntries)." entries in %d seconds",time()-$startTime));
1061
1062 0 closeMaybeGunzip($file, $fh);
1063
1064 0 $DB->commit();
1065 0 return($count);
1066 }
1067  
1068 sub importKeywords($$$$)
1069 0 ▶{
Subroutine importKeywords: not called CC=24 SCAR=64.0
Pod undocumented
1070 0 my ($self, $countEstimate, $file, $DB)=@_;
1071 0 my $startTime=time();
1072 0 my $lineCount=0;
1073  
1074 0 ▶ if ( $DB->table_row_count('Keywords') > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($DB->table_row_count("Keywords") > 0) 0 0 0
1075 0 $self->status("clearing previously loaded data..");
1076 0 $DB->table_clear('Keywords');
1077 }
1078  
1079 0 ▶ my $fh = openMaybeGunzip($file) || return(-2);
Condition0%0/2
&openMaybeGunzip($file) || (return -2)
l!l
00
MC/DC0%0/1
&openMaybeGunzip($file) || (return -2)
&openMaybeGunzip($file)
Truth table0%0/2
A
A= &openMaybeGunzip($file)
Aresult
11
00
1080 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
1081 0 $lineCount++;
1082  
1083 0 ▶ if ( m/THE KEYWORDS LIST/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (/THE KEYWORDS LIST/) { } 0 0 0
elsif ($lineCount > 200000) { } 0 0 0
1084 0 ▶ if ( !($_=<$fh>) || !m/^===========/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^===========/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^===========/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^===========/o
$_ = readline $fh /^===========/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^===========/o
ABresult
0X0
100
111
1085 0 $self->error("missing ======= after \"THE KEYWORDS LIST\" at line $lineCount");
1086 0 closeMaybeGunzip($file, $fh);
1087 0 return(-1);
1088 }
1089 0 ▶ if ( !($_=<$fh>) || !m/^\s*$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^\s*$/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^\s*$/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^\s*$/o
$_ = readline $fh /^\s*$/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^\s*$/o
ABresult
0X0
100
111
1090 0 $self->error("missing empty line after ======= at line $lineCount");
1091 0 closeMaybeGunzip($file, $fh);
1092 0 return(-1);
1093 }
1094 0 last;
1095 }
1096 elsif ( $lineCount > 200000 ) {
1097 0 $self->error("$file: stopping at line $lineCount, didn't see \"THE KEYWORDS LIST\" line");
1098 0 closeMaybeGunzip($file, $fh);
1099 0 return(-1);
1100 }
1101 }
1102  
1103 my $progress=Term::ProgressBar->new({name => "importing Keywords",
1104 count => $countEstimate,
1105 ETA => 'linear'})
1106 0 ▶ if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
1107  
1108 0 ▶ $progress->minor(0) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
1109 0 ▶ $progress->max_update_rate(1) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
1110 0 my $next_update=0;
1111  
1112 0 my $count=0;
1113 0 my $countImported=0;
1114 0 my %found;
1115 0 my $tableInsert_sth1=$DB->prepare('INSERT INTO Keywords (KeywordID, Name) VALUES (?,?)');
1116 0 my $tableInsert_sth2=$DB->prepare('INSERT INTO Titles2Keywords (TitleID, KeywordID) VALUES (?,?)');
1117 0 my $keywordCount=0;
1118 0 my $potentialEntries=0;
1119
1120 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
1121 0 $lineCount++;
1122 0 my $line=$_;
1123 0 chomp($line);
1124 0 ▶ next if ($line =~ m/^\s*$/);
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\s*$/ 0 0 0
1125
1126 0 $potentialEntries++;
1127
1128 0 my ($title, $keyword) = ($line =~ m/^(.*)\s+(\S+)\s*$/);
1129 0 ▶ if ( defined($title) and defined($keyword) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $title and defined $keyword) { } 0 0 0
Condition0%0/3
defined $title and defined $keyword
!ll&&!rl&&r
000
MC/DC0%0/2
defined $title and defined $keyword
defined $title defined $keyword
Truth table0%0/3
A and B
A= defined $titleB= defined $keyword
ABresult
0X0
100
111
1130  
1131 0 my ($episode) = $title =~ m/\s+(\{.*\})$/o;
1132
1133 0 ▶ if ( $self->{imdbMovie2DBKey}->{$title} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"imdbMovie2DBKey"}{$title}) 0 0 0
1134 0 ▶ if ( !defined($found{$keyword}) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $found{$keyword}) 0 0 0
1135 0 $keywordCount++;
1136
1137 0 $found{$keyword}=$keywordCount;
1138 0 $tableInsert_sth1->execute($keywordCount, $keyword);
1139 #=$DB->insert_row('Keywords', 'KeywordID', Name=>$keyword);
1140 }
1141 0 $tableInsert_sth2->execute($self->{imdbMovie2DBKey}->{$title}, $found{$keyword});
1142
1143 #$DB->insert_row('Titles2Keywords', undef, TitleID=>$self->{imdbMovie2DBKey}->{$title}, KeywordID=>$found{$keyword});
1144 0 $countImported++;
1145 0 ▶ if ( ($countImported % 50000) == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($countImported % 50000 == 0) 0 0 0
1146 0 $DB->commit();
1147 }
1148 }
1149 0 $count++;
1150 0 ▶ if ( $self->{showProgressBar} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"showProgressBar"}) 0 0 0
1151 # re-adjust target so progress bar doesn't seem too wonky
1152 0 ▶ if ( $count > $countEstimate ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($count > $countEstimate) { } 0 0 0
elsif ($count > $next_update) { } 0 0 0
1153 0 $countEstimate = $progress->target($count+1000);
1154 0 $next_update=$progress->update($count);
1155 }
1156 elsif ( $count > $next_update ) {
1157 0 $next_update=$progress->update($count);
1158 }
1159 }
1160 } else {
1161 0 $self->error("$file:$lineCount: unrecognized format \"$line\"");
1162 }
1163
1164 }
1165 0 ▶ $progress->update($countEstimate) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
1166  
1167 0 $self->status(sprintf("importing Keywords found ".withThousands($count)." in ".
1168 withThousands($potentialEntries)." entries in %d seconds",time()-$startTime));
1169  
1170 0 closeMaybeGunzip($file, $fh);
1171 0 $DB->commit();
1172 0 return($count);
1173 }
1174  
1175 sub importPlots($$$$)
1176 0 ▶{
Subroutine importPlots: not called CC=36 SCAR=71.9
Pod undocumented
1177 0 my ($self, $countEstimate, $file, $DB)=@_;
1178 0 my $startTime=time();
1179 0 my $lineCount=0;
1180  
1181 0 ▶ if ( $DB->table_row_count('Plots') > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($DB->table_row_count("Plots") > 0) 0 0 0
1182 0 $self->status("clearing previously loaded data..");
1183 0 $DB->table_clear('Plots');
1184 }
1185  
1186 0 ▶ my $fh = openMaybeGunzip($file) || return(-2);
Condition0%0/2
&openMaybeGunzip($file) || (return -2)
l!l
00
MC/DC0%0/1
&openMaybeGunzip($file) || (return -2)
&openMaybeGunzip($file)
Truth table0%0/2
A
A= &openMaybeGunzip($file)
Aresult
11
00
1187 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
1188 0 $lineCount++;
1189  
1190 0 ▶ if ( m/PLOT SUMMARIES LIST/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (/PLOT SUMMARIES LIST/) { } 0 0 0
elsif ($lineCount > 500) { } 0 0 0
1191 0 ▶ if ( !($_=<$fh>) || !m/^===========/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^===========/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^===========/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^===========/o
$_ = readline $fh /^===========/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^===========/o
ABresult
0X0
100
111
1192 0 $self->error("missing ======= after \"PLOT SUMMARIES LIST\" at line $lineCount");
1193 0 closeMaybeGunzip($file, $fh);
1194 0 return(-1);
1195 }
1196 0 ▶ if ( !($_=<$fh>) || !m/^-----------/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ = readline $fh and /^-----------/o) 0 0 0
Condition0%0/3
$_ = readline $fh and /^-----------/o
!ll&&!rl&&r
000
MC/DC0%0/2
$_ = readline $fh and /^-----------/o
$_ = readline $fh /^-----------/o
Truth table0%0/3
A and B
A= $_ = readline $fhB= /^-----------/o
ABresult
0X0
100
111
1197 0 $self->error("missing ------- line after ======= at line $lineCount");
1198 0 closeMaybeGunzip($file, $fh);
1199 0 return(-1);
1200 }
1201 0 last;
1202 }
1203 elsif ( $lineCount > 500 ) {
1204 0 $self->error("$file: stopping at line $lineCount, didn't see \"PLOT SUMMARIES LIST\" line");
1205 0 closeMaybeGunzip($file, $fh);
1206 0 return(-1);
1207 }
1208 }
1209  
1210 my $progress=Term::ProgressBar->new({name => "importing Plots",
1211 count => $countEstimate,
1212 ETA => 'linear'})
1213 0 ▶ if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
1214  
1215 0 ▶ $progress->minor(0) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
1216 0 ▶ $progress->max_update_rate(1) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
1217 0 my $next_update=0;
1218  
1219 0 my $count=0;
1220 0 my $potentialEntries=0;
1221 0 my $tableInsert_sth=$DB->prepare('INSERT INTO Plots (TitleID, Sequence, Description, Author) VALUES (?,?,?,?)');
1222 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
1223 0 $lineCount++;
1224 0 my $line=$_;
1225 0 chomp($line);
1226 0 ▶ next if ($line =~ m/^\s*$/);
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\s*$/ 0 0 0
1227 0 ▶ next if ($line=~m/\s*\{\{SUSPENDED\}\}/o);
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /\s*\{\{SUSPENDED\}\}/o 0 0 0
1228
1229 0 $potentialEntries++;
1230  
1231 0 my ($title, $episode) = ($line =~ m/^MV:\s(.*?)\s?(\{.*\})?$/);
1232 0 ▶ if ( defined($title) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $title) { } 0 0 0
1233
1234 0 $line =~s/^MV:\s*//;
1235  
1236 0 my $sequence=1;
1237 0 my $plot = '';
1238  
1239 0 ▶ while ( my $l = <$fh> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $l = readline $fh)) 0 0 0
1240 0 $lineCount++;
1241 0 chomp($l);
1242
1243 0 ▶ next if ($l =~ m/^\s*$/);
Branch: 1 branch
BranchTrueFalseTotal
if $l =~ /^\s*$/ 0 0 0
1244
1245 0 ▶ if ( $l =~ m/PL:\s(.*)$/ ) { # plot summary is a number of lines starting "PL:"
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ /PL:\s(.*)$/) 0 0 0
1246 0 ▶ $plot .= ($plot ne '' ?' ':'') . $1;
Branch: 1 branch
BranchTrueFalseTotal
$plot ne '' ? : 0 0 0
1247 }
1248  
1249 0 ▶ if ( $l =~ m/BY:\s(.*)$/ || $l =~ m/^(\-\-\-\-\-\-\-\-)/o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ /BY:\s(.*)$/ or $l =~ /^(\-\-\-\-\-\-\-\-)/o) 0 0 0
Condition0%0/3
$l =~ /BY:\s(.*)$/ or $l =~ /^(\-\-\-\-\-\-\-\-)/o
l!l&&r!l&&!r
000
MC/DC0%0/2
$l =~ /BY:\s(.*)$/ or $l =~ /^(\-\-\-\-\-\-\-\-)/o
$l =~ /BY:\s(.*)$/ $l =~ /^(\-\-\-\-\-\-\-\-)/o
Truth table0%0/3
A or B
A= $l =~ /BY:\s(.*)$/B= $l =~ /^(\-\-\-\-\-\-\-\-)/o
ABresult
1X1
011
000
1250 0 my $token=$1;
1251 0 my $author=$1;
1252
1253 0 ▶ if ( $token eq "\-\-\-\-\-\-\-\-" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token eq "--------") 0 0 0
1254 0 ▶ if ( $plot eq '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($plot eq "") 0 0 0
1255 0 last;
1256 }
1257 0 $author='';
1258 }
1259
1260 0 ▶ if ( $self->{imdbMovie2DBKey}->{$line} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'imdbMovie2DBKey'}{$line}) { } 0 0 0
1261 0 $tableInsert_sth->execute($self->{imdbMovie2DBKey}->{$line}, $sequence, $plot, $author);
1262
1263 0 $count++;
1264 0 ▶ if ( ($count % 50000) == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count % 50000 == 0) 0 0 0
1265 0 $DB->commit();
1266 }
1267 }
1268 else {
1269 0 $self->error("$lineCount: unable to match title key '$line'");
1270 }
1271
1272 0 $plot='';
1273 0 $sequence++;
1274  
1275 0 ▶ if ( $token eq "\-\-\-\-\-\-\-\-" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token eq "--------") 0 0 0
1276 0 last;
1277 }
1278 }
1279 }
1280  
1281 0 ▶ if ( length($plot) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $plot) 0 0 0
1282 0 $self->error("$lineCount: truncated plot with title key '$line'");
1283 }
1284
1285 0 ▶ if ( $self->{showProgressBar} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"showProgressBar"}) 0 0 0
1286 # re-adjust target so progress bar doesn't seem too wonky
1287 0 ▶ if ( $count > $countEstimate ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($count > $countEstimate) { } 0 0 0
elsif ($count > $next_update) { } 0 0 0
1288 0 $countEstimate = $progress->target($count+1000);
1289 0 $next_update=$progress->update($count);
1290 }
1291 elsif ( $count > $next_update ) {
1292 0 $next_update=$progress->update($count);
1293 }
1294 }
1295 } else {
1296 # skip lines up to the next "MV:"
1297 0 ▶ if ($line !~ m/^(---|PL:|BY:)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^(---|PL:|BY:)/) 0 0 0
1298 0 $self->error("$file:$lineCount: unrecognized format \"$line\"");
1299 }
1300 #$next_update=$progress->update($count) if ($self->{showProgressBar});
1301 0 ▶ if ( $count > $next_update ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count > $next_update) 0 0 0
1302 0 ▶ if ($self->{showProgressBar}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"showProgressBar"}) 0 0 0
1303 0 $next_update=$progress->update($count) ;
1304 0 warn "next $count -> $next_update";
1305 }
1306 }
1307 }
1308 }
1309 0 ▶ $progress->update($countEstimate) if ($self->{showProgressBar});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"showProgressBar"} 0 0 0
1310  
1311 0 $self->status(sprintf("importing Plots found ".withThousands($count)." in ".
1312 withThousands($potentialEntries)." entries in %d seconds",time()-$startTime));
1313  
1314 0 closeMaybeGunzip($file, $fh);
1315 0 $DB->commit();
1316 0 return($count);
1317 }
1318  
1319 sub loadDBInfo($)
1320 0 ▶{
Subroutine loadDBInfo: not called CC=4 SCAR=30.0
Pod undocumented
1321 0 my $file=shift;
1322 0 my $info;
1323  
1324 0 ▶ open(INFO, "< $file") || return("imdbDir index file \"$file\":$!");
Branch: 1 branch
BranchTrueFalseTotal
open INFO, "< $file" or return qq[imdbDir index file "$file":$!] 0 0 0
1325 0 ▶ while(<INFO>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline INFO)) 0 0 0
1326 0 chop();
1327 0 ▶ if ( s/^([^:]+)://o ) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^([^:]+)://o) 0 0 0
1328 0 $info->{$1}=$_;
1329 }
1330 }
1331 0 close(INFO);
1332 0 return($info);
1333 }
1334  
1335 sub dbinfoLoad($)
1336 0 ▶{
Subroutine dbinfoLoad: not called CC=2 SCAR=17.9
Pod undocumented
1337 0 my $self=shift;
1338  
1339 0 my $info=loadDBInfo($self->{moviedbInfo});
1340 0 ▶ if ( ref $info ne 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $info ne "HASH") 0 0 0
1341 0 return(1);
1342 }
1343 0 $self->{dbinfo}=$info;
1344 0 return(undef);
1345 }
1346  
1347 sub dbinfoAdd($$$)
1348 0 ▶{
Subroutine dbinfoAdd: not called CC=1 SCAR=6.9
Pod undocumented
1349 0 my ($self, $key, $value)=@_;
1350 0 $self->{dbinfo}->{$key}=$value;
1351 }
1352  
1353 sub dbinfoGet($$$)
1354 0 ▶{
Subroutine dbinfoGet: not called CC=2 SCAR=17.9
Pod undocumented
1355 0 my ($self, $key, $defaultValue)=@_;
1356 0 ▶ if ( defined($self->{dbinfo}->{$key}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"dbinfo"}{$key}) 0 0 0
1357 0 return($self->{dbinfo}->{$key});
1358 }
1359 0 return($defaultValue);
1360 }
1361  
1362 sub dbinfoSave($)
1363 0 ▶{
Subroutine dbinfoSave: not called CC=3 SCAR=24.8
Pod undocumented
1364 0 my $self=shift;
1365 0 ▶ open(INFO, "> $self->{moviedbInfo}") || return(1);
Branch: 1 branch
BranchTrueFalseTotal
open INFO, qq[> $self->{"moviedbInfo"}] or return 1 0 0 0
1366 0 for (sort keys %{$self->{dbinfo}}) {
1367 0 print INFO "".$_.":".$self->{dbinfo}->{$_}."\n";
1368 }
1369 0 close(INFO);
1370 0 return(0);
1371 }
1372  
1373 sub dbinfoGetFileSize($$)
1374 0 ▶{
Subroutine dbinfoGetFileSize: not called CC=7 SCAR=40.3
Pod undocumented
1375 0 my ($self, $key)=@_;
1376
1377  
1378 0 ▶ if ( !defined($self->{listFiles}->paths_isset($key) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"listFiles"}->paths_isset($key)) 0 0 0
1379 0 die ("invalid call for $key");
1380 }
1381 0 my $filePath=$self->{listFiles}->paths_index($key);
1382 0 ▶ if ( ! -f $filePath ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $filePath) 0 0 0
1383 0 return(0);
1384 }
1385  
1386 0 my $fileSize=int(-s $filePath);
1387  
1388 # if compressed, then attempt to run gzip -l
1389 0 ▶ if ( $filePath=~m/.gz$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filePath =~ /.gz$/) 0 0 0
1390 0 ▶ if ( open(my $fd, "gzip -l $filePath |") ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fd, "gzip -l $filePath |") { } 0 0 0
1391 # if parse fails, then defalt to wild ass guess of compression of 65%
1392 0 $fileSize=int(($fileSize*100)/(100-65));
1393  
1394 0 ▶ while(<$fd>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fd)) 0 0 0
1395 0 ▶ if ( m/^\s*\d+\s+(\d+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^\s*\d+\s+(\d+)/) 0 0 0
1396 0 $fileSize=$1;
1397 }
1398 }
1399 0 close($fd);
1400 }
1401 else {
1402 # wild ass guess of compression of 65%
1403 0 $fileSize=int(($fileSize*100)/(100-65));
1404 }
1405 }
1406 0 return($fileSize);
1407 }
1408  
1409 sub _redirect($$)
1410 0 ▶{
Subroutine _redirect: not called CC=3 SCAR=24.8
1411 0 my ($self, $file)=@_;
1412
1413 0 ▶ if ( defined($file) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $file) { } 0 0 0
1414 0 ▶ if ( !open($self->{logfd}, "> $file") ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open $self->{"logfd"}, "> $file") 0 0 0
1415 0 print STDERR "$file:$!\n";
1416 0 return(0);
1417 }
1418 0 $self->{errorCountInLog}=0;
1419 }
1420 else {
1421 0 close($self->{logfd});
1422 0 $self->{logfd}=undef;
1423 }
1424 0 return(1);
1425 }
1426  
1427 =head2 importListComplete
1428  
1429 Check to see if spcified list file has been successfully imported
1430  
1431 =cut
1432  
1433 sub importListComplete($)
1434 0 ▶{
Subroutine importListComplete: not called CC=2 SCAR=17.9
Pod documented
1435 0 my ($self, $type)=@_;
1436  
1437 0 ▶ if ( -f "$self->{imdbDir}/stage-$type.log" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f qq[$self->{"imdbDir"}/stage-$type.log]) 0 0 0
1438 0 return(1);
1439 }
1440 0 return(0);
1441 }
1442  
1443 sub _prepStage
1444 0 ▶{
Subroutine _prepStage: not called CC=5 SCAR=34.0
1445 0 my ($self, $type)=@_;
1446
1447 0 my $DB=new IMDB::Local::DB(database=>"$self->{imdbDir}/imdb.db");
1448  
1449 # if we're restarting, lets start fresh
1450 0 ▶ if ( $type eq 'movies' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "movies") 0 0 0
1451 #warn("recreating db ".$DB->database());
1452 0 $DB->delete();
1453  
1454 0 for my $type ( $self->listTypes() ) {
1455 0 unlink("$self->{imdbDir}/stage-$type.log");
1456 }
1457  
1458 }
1459
1460 0 ▶ if ( !$self->_redirect(sprintf("%s/stage-$type.log", $self->{imdbDir})) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_redirect(sprintf("%s/stage-$type.log", $self->{"imdbDir"}))) 0 0 0
1461 0 return(1);
1462 }
1463
1464 0 ▶ if ( !$DB->connect() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($DB->connect) 0 0 0
1465 0 die "imdbdb connect failed:$DBI::errstr";
1466 }
1467  
1468 0 $DB->runSQL("PRAGMA synchronous = OFF");
1469 0 return($DB);
1470  
1471 }
1472  
1473 sub _unprepStage
1474 0 ▶{
Subroutine _unprepStage: not called CC=1 SCAR=6.9
1475 0 my ($self, $db)=@_;
1476
1477 0 $db->commit();
1478 0 $db->disconnect();
1479  
1480 0 $self->_redirect(undef);
1481 }
1482  
1483 sub _importListFile($$$)
1484 0 ▶{
Subroutine _importListFile: not called CC=41 SCAR=74.5
1485 0 my ($self, $DB, $type)=@_;
1486  
1487  
1488 0 ▶ if ( !grep(/^$type$/, $self->listTypes()) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep /^$type$/, $self->listTypes) 0 0 0
1489 0 die "invalid type $type";
1490 }
1491
1492 0 ▶ my $dbinfoCalcEstimate=sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1493 0 my ($self, $key)=@_;
1494
1495 0 my %estimateSizePerEntry=(movies=>47,
1496 directors=>258,
1497 actors=>695,
1498 actresses=>779,
1499 genres=>38,
1500 ratings=>68,
1501 keywords=>47,
1502 plot=>731);
1503 0 my $fileSize=$self->dbinfoGetFileSize($key);
1504
1505 0 my $countEstimate=int($fileSize/$estimateSizePerEntry{$key});
1506
1507 0 my $filePath=$self->{listFiles}->paths_index($key);
1508
1509 0 $self->dbinfoAdd($key."_list_file", $filePath);
1510 0 $self->dbinfoAdd($key."_list_file_size", "".int(-s $filePath));
1511 0 $self->dbinfoAdd($key."_list_file_size_uncompressed", $fileSize);
1512 0 $self->dbinfoAdd($key."_list_count_estimate", $countEstimate);
1513 0 return($countEstimate);
1514 0 };
1515  
1516 0 ▶ my $dbinfoCalcBytesPerEntry = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1517 0 my ($self, $key, $calcActualForThisNumber)=@_;
1518 0 my $fileSize=$self->dbinfoGetFileSize($key);
1519 0 return(int($fileSize/$calcActualForThisNumber));
1520 0 };
1521  
1522  
1523 0 ▶ if ( ! -f $self->{listFiles}->paths_index($type) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $self->{"listFiles"}->paths_index($type)) 0 0 0
1524 0 $self->status("no $type file available");
1525 0 return(1);
1526 }
1527  
1528 0 ▶ if ( $type eq 'movies') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "movies") 0 0 0
1529  
1530 0 $DB->drop_table_indexes('Titles');
1531
1532 0 my $countEstimate=&$dbinfoCalcEstimate($self, "movies");
1533  
1534 0 my $num=$self->importMovies($countEstimate, $self->{listFiles}->paths_index('movies'), $DB);
1535 0 ▶ if ( $num < 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($num < 0) { } 0 0 0
elsif (abs $num - $countEstimate > $countEstimate * 0.1) { } 0 0 0
1536 0 ▶ if ( $num == -2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num == -2) 0 0 0
1537 0 $self->error("you need to download ".$self->{listFiles}->paths_index('movies')." from ftp.imdb.com");
1538 }
1539 0 return(1);
1540 }
1541 elsif ( abs($num - $countEstimate) > $countEstimate*.10 ) {
1542 0 my $better=&$dbinfoCalcBytesPerEntry($self, "movies", $num);
1543 0 $self->status("ARG estimate of $countEstimate for movies needs updating, found $num ($better bytes/entry)");
1544 }
1545  
1546 0 ▶ open(OUT, "> $self->{imdbDir}/titles.tsv") || die "$self->{imdbDir}/titles.tsv:$!";
Branch: 1 branch
BranchTrueFalseTotal
open OUT, qq[> $self->{"imdbDir"}/titles.tsv] or die qq[$self->{"imdbDir"}/titles.tsv:$!] 0 0 0
1547 0 for my $mkey (sort keys %{$self->{imdbMovie2DBKey}}) {
1548 0 print OUT "".$self->{imdbMovie2DBKey}->{$mkey}."\t".$mkey."\n";
1549 }
1550 0 close(OUT);
1551  
1552 0 $self->dbinfoAdd("db_stat_movie_count", "$num");
1553  
1554 0 $self->status("Creating Table indexes..");
1555 0 $DB->create_table_indexes('Titles');
1556  
1557 0 return(0);
1558 }
1559  
1560 # read in keys so we have them for follow-up stages
1561 0 ▶ if ( !defined($self->{imdbMovie2DBKey}) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"imdbMovie2DBKey"}) 0 0 0
1562 #$self->{imdbMovie2DBKey}=$DB->select2Hash("select IMDBKey, TitleID from Titles");
1563
1564 0 if ( 1 ) {
1565 0 ▶ open(IN, "< $self->{imdbDir}/titles.tsv") || die "$self->{imdbDir}/titles.tsv:$!";
Branch: 1 branch
BranchTrueFalseTotal
open IN, qq[< $self->{"imdbDir"}/titles.tsv] or die qq[$self->{"imdbDir"}/titles.tsv:$!] 0 0 0
1566 0 ▶ while (<IN>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline IN)) 0 0 0
1567 0 chomp();
1568 0 ▶ if ( m/^(\d+)\t(.+)/o ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^(\d+)\t(.+)/o) 0 0 0
1569 0 $self->{imdbMovie2DBKey}->{$2}=$1;
1570 }
1571 }
1572 0 close(IN);
1573 }
1574 }
1575  
1576 # need to read-movie kesy
1577 0 ▶ if ( $type eq 'directors') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "directors") 0 0 0
1578  
1579 0 $DB->drop_table_indexes('Directors');
1580
1581 0 my $countEstimate=&$dbinfoCalcEstimate($self, "directors");
1582  
1583 0 my $num=$self->importDirectors($countEstimate, $self->{listFiles}->paths_index('directors'), $DB);
1584 0 ▶ if ( $num < 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($num < 0) { } 0 0 0
elsif (abs $num - $countEstimate > $countEstimate * 0.1) { } 0 0 0
1585 0 ▶ if ( $num == -2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num == -2) 0 0 0
1586 0 $self->error("you need to download ".$self->{listFiles}->paths_index('directors')." from ftp.imdb.com (see http://www.imdb.com/interfaces)");
1587 }
1588 0 return(1);
1589 }
1590 elsif ( abs($num - $countEstimate) > $countEstimate*.10 ) {
1591 0 my $better=&$dbinfoCalcBytesPerEntry($self, "directors", $num);
1592 0 $self->status("ARG estimate of $countEstimate for directors needs updating, found $num ($better bytes/entry)");
1593 }
1594 0 $self->dbinfoAdd("db_stat_director_count", "$num");
1595
1596 0 $self->status("Creating Table indexes..");
1597 0 $DB->create_table_indexes('Directors');
1598  
1599 0 return(0);
1600 }
1601  
1602 0 ▶ if ( $type eq 'actors') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "actors") 0 0 0
1603 0 $DB->drop_table_indexes('Actors');
1604  
1605 #print "re-reading movies into memory for reverse lookup..\n";
1606 0 my $countEstimate=&$dbinfoCalcEstimate($self, "actors");
1607  
1608 #my $num=$self->readCast("Actors", $countEstimate, "$self->{imdbListFiles}->{actors}");
1609 0 my $num=$self->importActors("Actors", $countEstimate, $self->{listFiles}->paths_index('actors'), $DB);
1610 0 ▶ if ( $num < 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($num < 0) { } 0 0 0
elsif (abs $num - $countEstimate > $countEstimate * 0.1) { } 0 0 0
1611 0 ▶ if ( $num == -2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num == -2) 0 0 0
1612 0 $self->error("you need to download ".$self->{listFiles}->paths_index('actors')." from ftp.imdb.com (see http://www.imdb.com/interfaces)");
1613 }
1614 0 return(1);
1615 }
1616 elsif ( abs($num - $countEstimate) > $countEstimate*.10 ) {
1617 0 my $better=&$dbinfoCalcBytesPerEntry($self, "actors", $num);
1618 0 $self->status("ARG estimate of $countEstimate for actors needs updating, found $num ($better bytes/entry)");
1619 }
1620 0 $self->dbinfoAdd("db_stat_actor_count", "$num");
1621 0 return(0);
1622 }
1623
1624 0 ▶ if ( $type eq 'actresses') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "actresses") 0 0 0
1625  
1626 0 my $countEstimate=&$dbinfoCalcEstimate($self, "actresses");
1627 0 my $num=$self->importActors("Actresses", $countEstimate, $self->{listFiles}->paths_index('actresses'), $DB);
1628 0 ▶ if ( $num < 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($num < 0) { } 0 0 0
elsif (abs $num - $countEstimate > $countEstimate * 0.1) { } 0 0 0
1629 0 ▶ if ( $num == -2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num == -2) 0 0 0
1630 0 $self->error("you need to download ".$self->{listFiles}->paths_index('actresses')." from ftp.imdb.com (see http://www.imdb.com/interfaces)");
1631 }
1632 0 return(1);
1633 }
1634 elsif ( abs($num - $countEstimate) > $countEstimate*.10 ) {
1635 0 my $better=&$dbinfoCalcBytesPerEntry($self, "actresses", $num);
1636 0 $self->status("ARG estimate of $countEstimate for actresses needs updating, found $num ($better bytes/entry)");
1637 }
1638 0 $self->dbinfoAdd("db_stat_actress_count", "$num");
1639
1640 0 $self->status("Creating Table indexes..");
1641 0 $DB->create_table_indexes('Actors');
1642
1643 0 return(0);
1644 }
1645
1646 0 ▶ if ( $type eq 'genres') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "genres") 0 0 0
1647 0 $DB->drop_table_indexes('Genres');
1648
1649 0 my $countEstimate=&$dbinfoCalcEstimate($self, "genres");
1650  
1651 0 my $num=$self->importGenres($countEstimate, $self->{listFiles}->paths_index('genres'), $DB);
1652 0 ▶ if ( $num < 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($num < 0) { } 0 0 0
elsif (abs $num - $countEstimate > $countEstimate * 0.1) { } 0 0 0
1653 0 ▶ if ( $num == -2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num == -2) 0 0 0
1654 0 $self->error("you need to download ".$self->{listFiles}->paths_index('genres')." from ftp.imdb.com");
1655 }
1656 0 return(1);
1657 }
1658 elsif ( abs($num - $countEstimate) > $countEstimate*.10 ) {
1659 0 my $better=&$dbinfoCalcBytesPerEntry($self, "genres", $num);
1660 0 $self->status("ARG estimate of $countEstimate for genres needs updating, found $num ($better bytes/entry)");
1661 }
1662 0 $self->dbinfoAdd("db_stat_genres_count", "$num");
1663
1664 0 $self->status("Creating Table indexes..");
1665 0 $DB->create_table_indexes('Genres');
1666  
1667 0 return(0);
1668 }
1669
1670 0 ▶ if ( $type eq 'ratings') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "ratings") 0 0 0
1671 0 $DB->drop_table_indexes('Ratings');
1672
1673 0 my $countEstimate=&$dbinfoCalcEstimate($self, "ratings");
1674  
1675 0 my $num=$self->importRatings($countEstimate, $self->{listFiles}->paths_index('ratings'), $DB);
1676 0 ▶ if ( $num < 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($num < 0) { } 0 0 0
elsif (abs $num - $countEstimate > $countEstimate * 0.1) { } 0 0 0
1677 0 ▶ if ( $num == -2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num == -2) 0 0 0
1678 0 $self->error("you need to download ".$self->{listFiles}->paths_index('ratings')." from ftp.imdb.com");
1679 }
1680 0 return(1);
1681 }
1682 elsif ( abs($num - $countEstimate) > $countEstimate*.10 ) {
1683 0 my $better=&$dbinfoCalcBytesPerEntry($self, "ratings", $num);
1684 0 $self->status("ARG estimate of $countEstimate for ratings needs updating, found $num ($better bytes/entry)");
1685 }
1686 0 $self->dbinfoAdd("db_stat_ratings_count", "$num");
1687  
1688 0 $self->status("Creating Table indexes..");
1689 0 $DB->create_table_indexes('Ratings');
1690  
1691 0 return(0);
1692 }
1693
1694 0 ▶ if ( $type eq 'keywords') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "keywords") 0 0 0
1695 0 $DB->drop_table_indexes('Keywords');
1696
1697 0 my $countEstimate=&$dbinfoCalcEstimate($self, "keywords");
1698 #my $countEstimate=5554178;
1699  
1700 0 my $num=$self->importKeywords($countEstimate, $self->{listFiles}->paths_index('keywords'), $DB);
1701 0 ▶ if ( $num < 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($num < 0) { } 0 0 0
elsif (abs $num - $countEstimate > $countEstimate * 0.05) { } 0 0 0
1702 0 ▶ if ( $num == -2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num == -2) 0 0 0
1703 0 $self->error("you need to download ".$self->{listFiles}->paths_index('keywords')." from ftp.imdb.com");
1704 }
1705 0 return(1);
1706 }
1707 elsif ( abs($num - $countEstimate) > $countEstimate*.05 ) {
1708 0 $self->status("ARG estimate of $countEstimate for keywords needs updating, found $num");
1709 }
1710 0 $self->dbinfoAdd("keywords_list_file", $self->{listFiles}->paths_index('keywords'));
1711 0 $self->dbinfoAdd("keywords_list_file_size", -s $self->{listFiles}->paths_index('keywords'));
1712 0 $self->dbinfoAdd("db_stat_keywords_count", "$num");
1713  
1714 0 $self->status("Creating Table indexes..");
1715 0 $DB->create_table_indexes('Keywords');
1716  
1717 0 return(0);
1718 }
1719  
1720 0 ▶ if ( $type eq 'plot') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "plot") 0 0 0
1721 0 $DB->drop_table_indexes('Plots');
1722
1723 0 my $countEstimate=&$dbinfoCalcEstimate($self, "plot");
1724 0 my $num=$self->importPlots($countEstimate, $self->{listFiles}->paths_index('plot'), $DB);
1725 0 ▶ if ( $num < 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($num < 0) { } 0 0 0
elsif (abs $num - $countEstimate > $countEstimate * 0.05) { } 0 0 0
1726 0 ▶ if ( $num == -2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num == -2) 0 0 0
1727 0 $self->error("you need to download ".$self->{listFiles}->paths_index('plot')." from ftp.imdb.com");
1728 }
1729 0 return(1);
1730 }
1731 elsif ( abs($num - $countEstimate) > $countEstimate*.05 ) {
1732 0 $self->status("ARG estimate of $countEstimate for plots needs updating, found $num");
1733 }
1734 0 $self->dbinfoAdd("plots_list_file", $self->{listFiles}->paths_index('plot'));
1735 0 $self->dbinfoAdd("plots_list_file_size", -s $self->{listFiles}->paths_index('plot'));
1736 0 $self->dbinfoAdd("db_stat_plots_count", "$num");
1737
1738 0 $self->status("Creating Table indexes..");
1739 0 $DB->create_table_indexes('Plots');
1740
1741 0 return(0);
1742 }
1743  
1744 0 $self->error("invalid type $type");
1745 0 return(1);
1746 }
1747  
1748 =head2 importList
1749  
1750 Import a list file from 'listsDir' into the IMDB::Local Database.
1751 Note: when 'movies' type is specified the database is reset from scratch
1752  
1753 =cut
1754  
1755 sub importList($$)
1756 0 ▶{
Subroutine importList: not called CC=2 SCAR=17.9
Pod documented
1757 0 my ($self, $type)=@_;
1758  
1759 0 my $DB=$self->_prepStage($type);
1760  
1761 # lets load our stats
1762 0 $self->dbinfoLoad();
1763  
1764 0 my $startTime=time();
1765 0 ▶ if ( $self->_importListFile($DB, $type) != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_importListFile($DB, $type) != 0) 0 0 0
1766 0 $DB->disconnect();
1767 0 return(1);
1768 }
1769  
1770 0 $self->dbinfoAdd("seconds_to_complete_prep_stage_$type", (time()-$startTime));
1771 0 $self->dbinfoSave();
1772  
1773 0 $self->_unprepStage($DB);
1774 0 return(0);
1775 }
1776  
1777 =head2 importAll
1778  
1779 Import all available list files from 'listsDir' into the IMDB::Local Database.
1780 Returns # of list files that produced errors.
1781  
1782 =cut
1783  
1784 sub importAll($$)
1785 0 ▶{
Subroutine importAll: not called CC=3 SCAR=24.8
Pod documented
1786 0 my ($self, $type)=@_;
1787  
1788 0 my $err=0;
1789 0 for my $type ( $self->listTypes() ) {
1790 0 ▶ if ( $self->importList($type) != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->importList($type) != 0) 0 0 0
1791 0 warn("list import $type failed to load, $self->{errorCountInLog} errors in $self->{imdbDir}/stage-$type.log");
1792 0 $err++;
1793 }
1794 }
1795 0 return($err);
1796 }
1797  
1798 =head2 optimize
1799  
1800 Optimize the database for better performance.
1801  
1802 =cut
1803 sub optimize($)
1804 0 ▶{
Subroutine optimize: not called CC=2 SCAR=17.9
Pod documented
1805 0 my ($self)=@_;
1806  
1807 0 my $DB=new IMDB::Local::DB(database=>"$self->{imdbDir}/imdb.db", db_AutoCommit=>1);
1808
1809 0 ▶ if ( !$DB->connect() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($DB->connect) 0 0 0
1810 0 die "imdbdb connect failed:$DBI::errstr";
1811 }
1812  
1813 0 $DB->runSQL("VACUUM");
1814 0 $DB->disconnect();
1815 0 return(1);
1816 }
1817  
1818 sub _NOT_USED_checkSantity($)
1819 0 ▶{
Subroutine _NOT_USED_checkSantity: not called CC=9 SCAR=45.0
1820 0 my ($self)=@_;
1821  
1822 0 $self->dbinfoAdd("db_version", $IMDB::Local::VERSION);
1823  
1824 0 ▶ if ( $self->dbinfoSave() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->dbinfoSave) 0 0 0
1825 0 $self->error("$self->{moviedbInfo}:$!");
1826 0 return(1);
1827 }
1828
1829 0 $self->status("running quick sanity check on database indexes...");
1830 my $imdb=new IMDB::Local('imdbDir' => $self->{imdbDir},
1831 0 'verbose' => $self->{verbose});
1832
1833 0 ▶ if ( -e "$self->{moviedbOffline}" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e qq[$self->{"moviedbOffline"}]) 0 0 0
1834 0 unlink("$self->{moviedbOffline}");
1835 }
1836
1837 0 ▶ if ( my $errline=$imdb->sanityCheckDatabase() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $errline = $imdb->sanityCheckDatabase) 0 0 0
1838 0 ▶ open(OFF, "> $self->{moviedbOffline}") || die "$self->{moviedbOffline}:$!";
Branch: 1 branch
BranchTrueFalseTotal
open OFF, qq[> $self->{"moviedbOffline"}] or die qq[$self->{"moviedbOffline"}:$!] 0 0 0
1839 0 print OFF $errline."\n";
1840 0 print OFF "one of the prep stages' must have produced corrupt data\n";
1841 0 print OFF "report the following details to xmltv-devel\@lists.sf.net\n";
1842
1843 0 my $info=loadDBInfo($self->{moviedbInfo});
1844 0 ▶ if ( ref $info eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $info eq 'HASH') { } 0 0 0
1845 0 for my $key (sort keys %{$info}) {
1846 0 print OFF "\t$key:$info->{$key}\n";
1847 }
1848 }
1849 else {
1850 0 print OFF "\tdbinfo file corrupt\n";
1851 0 print OFF "\t$info";
1852 }
1853 0 print OFF "database taken offline\n";
1854 0 close(OFF);
1855 0 ▶ open(OFF, "< $self->{moviedbOffline}") || die "$self->{moviedbOffline}:$!";
Branch: 1 branch
BranchTrueFalseTotal
open OFF, qq[< $self->{"moviedbOffline"}] or die qq[$self->{"moviedbOffline"}:$!] 0 0 0
1856 0 ▶ while(<OFF>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline OFF)) 0 0 0
1857 0 chop();
1858 0 $self->error($_);
1859 }
1860 0 close(OFF);
1861 0 return(1);
1862 }
1863 0 $self->status("sanity intact :)");
1864 0 return(0);
1865 }
1866  
1867 =head1 AUTHOR
1868  
1869 jerryv, C<< <jerry.veldhuis at gmail.com> >>
1870  
1871 =head1 BUGS
1872  
1873 Please report any bugs or feature requests to C<bug-imdb-local at rt.cpan.org>, or through
1874 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IMDB-Local>. I will be notified, and then you'll
1875 automatically be notified of progress on your bug as I make changes.
1876  
1877  
1878  
1879  
1880 =head1 SUPPORT
1881  
1882 You can find documentation for this module with the perldoc command.
1883  
1884 perldoc IMDB::Local
1885  
1886  
1887 You can also look for information at:
1888  
1889 =over 4
1890  
1891 =item * RT: CPAN's request tracker (report bugs here)
1892  
1893 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=IMDB-Local>
1894  
1895 =item * AnnoCPAN: Annotated CPAN documentation
1896  
1897 L<http://annocpan.org/dist/IMDB-Local>
1898  
1899 =item * CPAN Ratings
1900  
1901 L<http://cpanratings.perl.org/d/IMDB-Local>
1902  
1903 =item * Search CPAN
1904  
1905 L<http://search.cpan.org/dist/IMDB-Local/>
1906  
1907 =back
1908  
1909  
1910 =head1 ACKNOWLEDGEMENTS
1911  
1912  
1913 =head1 LICENSE AND COPYRIGHT
1914  
1915 Copyright 2015 jerryv.
1916  
1917 This program is free software; you can redistribute it and/or modify it
1918 under the terms of the the Artistic License (2.0). You may obtain a
1919 copy of the full license at:
1920  
1921 L<http://www.perlfoundation.org/artistic_license_2_0>
1922  
1923 Any use, modification, and distribution of the Standard or Modified
1924 Versions is governed by this Artistic License. By using, modifying or
1925 distributing the Package, you accept this license. Do not use, modify,
1926 or distribute the Package, if you do not accept this license.
1927  
1928 If your Modified Version has been derived from a Modified Version made
1929 by someone other than you, you are nevertheless required to ensure that
1930 your Modified Version complies with the requirements of this license.
1931  
1932 This license does not grant you the right to use any trademark, service
1933 mark, tradename, or logo of the Copyright Holder.
1934  
1935 This license includes the non-exclusive, worldwide, free-of-charge
1936 patent license to make, have made, use, offer to sell, sell, import and
1937 otherwise transfer the Package with respect to any patent claims
1938 licensable by the Copyright Holder that are necessarily infringed by the
1939 Package. If you institute patent litigation (including a cross-claim or
1940 counterclaim) against any party alleging that the Package constitutes
1941 direct or contributory patent infringement, then this Artistic License
1942 to you shall terminate on the date that such litigation is filed.
1943  
1944 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
1945 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
1946 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
1947 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
1948 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
1949 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
1950 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
1951 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1952  
1953  
1954 =cut
1955  
1956 1 1; # End of IMDB::Local
↑ Summary lib/IMDB/Local/DB/Base.pm »