line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
2810
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package App::MP4Meta::Source::TVDB; |
6
|
|
|
|
|
|
|
{ |
7
|
|
|
|
|
|
|
$App::MP4Meta::Source::TVDB::VERSION = '1.153340'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Searches http://thetvbd.com for TV data. |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
10
|
use App::MP4Meta::Source::Base; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
13
|
|
|
|
|
|
|
our @ISA = 'App::MP4Meta::Source::Base'; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
8
|
use App::MP4Meta::Source::Data::TVEpisode; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
690
|
use WebService::TVDB 1.122800; |
|
1
|
|
|
|
|
141192
|
|
|
1
|
|
|
|
|
9
|
|
18
|
1
|
|
|
1
|
|
28
|
use File::Temp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
19
|
1
|
|
|
1
|
|
5
|
use LWP::Simple (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
5
|
use constant NAME => 'theTVDB.com'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
518
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
2
|
|
|
2
|
1
|
18076
|
my $class = shift; |
25
|
2
|
|
|
|
|
3
|
my $args = shift; |
26
|
2
|
|
|
|
|
15
|
my $self = $class->SUPER::new($args); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# TODO: specify language |
29
|
|
|
|
|
|
|
# TODO: API key? |
30
|
2
|
|
|
|
|
14
|
$self->{tvdb} = WebService::TVDB->new(); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub name { |
36
|
0
|
|
|
0
|
1
|
|
return NAME; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub get_tv_episode { |
40
|
0
|
|
|
0
|
1
|
|
my ( $self, $args ) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$self->SUPER::get_tv_episode($args); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $series_list = $self->{tvdb}->search( $args->{show_title} ); |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
die 'no series found' unless @$series_list; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# TODO: ability to search results i.e. by year |
49
|
0
|
|
|
|
|
|
my $series = @{$series_list}[0]; |
|
0
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $cover_file; |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
if ( $self->{cache}->{ $series->id } ) { |
53
|
0
|
|
|
|
|
|
$series = $self->{cache}->{ $series->id }; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# fetches full series data and cache |
58
|
0
|
|
|
|
|
|
$series->fetch(); |
59
|
0
|
|
|
|
|
|
$series = $self->{cache}->{ $series->id } = $series; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# get banner file and cache |
63
|
0
|
0
|
|
|
|
|
if ( $self->{banner_cache}->{ $series->id . '-S' . $args->{season} } ) { |
64
|
|
|
|
|
|
|
$cover_file = |
65
|
0
|
|
|
|
|
|
$self->{banner_cache}->{ $series->id . '-S' . $args->{season} }; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
else { |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$cover_file = |
70
|
|
|
|
|
|
|
$self->{banner_cache}->{ $series->id . '-S' . $args->{season} } = |
71
|
0
|
|
|
|
|
|
$self->_get_cover_file( $series, $args->{season} ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# get episode |
75
|
0
|
|
|
|
|
|
my $episode = $series->get_episode( $args->{season}, $args->{episode} ); |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return App::MP4Meta::Source::Data::TVEpisode->new( |
78
|
|
|
|
|
|
|
overview => $episode->Overview, |
79
|
|
|
|
|
|
|
title => $episode->EpisodeName, |
80
|
|
|
|
|
|
|
show_title => $series->SeriesName, |
81
|
|
|
|
|
|
|
genre => $series->Genre->[0], |
82
|
|
|
|
|
|
|
cover => $cover_file, |
83
|
|
|
|
|
|
|
year => $episode->year, |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# gets the cover file for the season and returns the filename |
88
|
|
|
|
|
|
|
# also stores in cache |
89
|
|
|
|
|
|
|
sub _get_cover_file { |
90
|
0
|
|
|
0
|
|
|
my ( $self, $series, $season ) = @_; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
for my $banner ( @{ $series->banners } ) { |
|
0
|
|
|
|
|
|
|
93
|
0
|
0
|
|
|
|
|
if ( $banner->BannerType2 eq 'season' ) { |
94
|
0
|
0
|
|
|
|
|
if ( $banner->Season eq $season ) { |
95
|
0
|
|
|
|
|
|
my $temp = File::Temp->new( SUFFIX => '.jpg' ); |
96
|
0
|
|
|
|
|
|
push @{ $self->{tempfiles} }, $temp; |
|
0
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
if ( |
98
|
|
|
|
|
|
|
LWP::Simple::is_success( |
99
|
|
|
|
|
|
|
LWP::Simple::getstore( $banner->url, $temp->filename ) |
100
|
|
|
|
|
|
|
) |
101
|
|
|
|
|
|
|
) |
102
|
|
|
|
|
|
|
{ |
103
|
0
|
|
|
|
|
|
return $temp->filename; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |