line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
2977
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
20
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
60
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package App::MP4Meta::Source::OMDB; |
6
|
|
|
|
|
|
|
{ |
7
|
|
|
|
|
|
|
$App::MP4Meta::Source::OMDB::VERSION = '1.153340'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Fetches film data from the OMDB. |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use App::MP4Meta::Source::Base; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
13
|
|
|
|
|
|
|
our @ISA = 'App::MP4Meta::Source::Base'; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
6
|
use App::MP4Meta::Source::Data::Film; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
688
|
use WebService::OMDB; |
|
1
|
|
|
|
|
12116
|
|
|
1
|
|
|
|
|
26
|
|
18
|
1
|
|
|
1
|
|
6
|
use File::Temp (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
15
|
|
19
|
1
|
|
|
1
|
|
6
|
use LWP::Simple (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
4
|
use constant NAME => 'OMDB'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
49
|
|
22
|
1
|
|
|
1
|
|
5
|
use constant PLOT => 'short'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
72
|
|
23
|
1
|
|
|
1
|
|
6
|
use constant RESPONSE => 'json'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
294
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
26
|
1
|
|
|
1
|
1
|
9442
|
my $class = shift; |
27
|
1
|
|
|
|
|
4
|
my $args = shift; |
28
|
1
|
|
|
|
|
14
|
my $self = $class->SUPER::new($args); |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
4
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub name { |
34
|
1
|
|
|
1
|
1
|
4792
|
return NAME; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub get_film { |
38
|
1
|
|
|
1
|
1
|
1011
|
my ( $self, $args ) = @_; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
7
|
$self->SUPER::get_film($args); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $result = WebService::OMDB::title( |
43
|
|
|
|
|
|
|
$args->{title}, |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
year => $args->{year}, |
46
|
1
|
|
|
|
|
11
|
plot => PLOT, |
47
|
|
|
|
|
|
|
r => RESPONSE |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# get cover file |
52
|
|
|
|
|
|
|
# FIXME: never set |
53
|
1
|
|
|
|
|
292023
|
my $cover_file; |
54
|
1
|
50
|
|
|
|
16
|
unless ($cover_file) { |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
7
|
my $poster = $result->{Poster}; |
57
|
1
|
|
|
|
|
10
|
$cover_file = $self->_get_cover_file($poster); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# FIXME: poster could be null. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return App::MP4Meta::Source::Data::Film->new( |
63
|
|
|
|
|
|
|
overview => $result->{Plot}, |
64
|
|
|
|
|
|
|
title => $result->{Title}, |
65
|
|
|
|
|
|
|
genre => $result->{Genre}, |
66
|
|
|
|
|
|
|
cover => $cover_file, |
67
|
|
|
|
|
|
|
year => $result->{Year}, |
68
|
1
|
|
|
|
|
43
|
); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# gets the cover file for the season and returns the filename |
72
|
|
|
|
|
|
|
# also stores in cache |
73
|
|
|
|
|
|
|
sub _get_cover_file { |
74
|
1
|
|
|
1
|
|
5
|
my ( $self, $url ) = @_; |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
21
|
my $temp = File::Temp->new( SUFFIX => '.jpg' ); |
77
|
1
|
|
|
|
|
1245
|
push @{ $self->{tempfiles} }, $temp; |
|
1
|
|
|
|
|
8
|
|
78
|
1
|
50
|
|
|
|
9
|
if ( |
79
|
|
|
|
|
|
|
LWP::Simple::is_success( |
80
|
|
|
|
|
|
|
LWP::Simple::getstore( $url, $temp->filename ) |
81
|
|
|
|
|
|
|
) |
82
|
|
|
|
|
|
|
) |
83
|
|
|
|
|
|
|
{ |
84
|
1
|
|
|
|
|
90384
|
return $temp->filename; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |