line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
2748
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package App::MP4Meta::Film; |
6
|
|
|
|
|
|
|
{ |
7
|
|
|
|
|
|
|
$App::MP4Meta::Film::VERSION = '1.153340'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Add metadata to a film |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use App::MP4Meta::Base; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
13
|
|
|
|
|
|
|
our @ISA = 'App::MP4Meta::Base'; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use File::Spec '3.33'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
16
|
1
|
|
|
1
|
|
5
|
use AtomicParsley::Command::Tags; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
591
|
use App::MP4Meta::Source::Data::Film; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
3
|
|
|
3
|
1
|
10976
|
my $class = shift; |
22
|
3
|
|
|
|
|
7
|
my $args = shift; |
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
|
|
22
|
my $self = $class->SUPER::new($args); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Of course, its a movie, but this fixes the |
27
|
|
|
|
|
|
|
# 'Home Video' problem in iTunes 11. |
28
|
0
|
|
|
|
|
0
|
$self->{'media_type'} = 'Short Film'; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub apply_meta { |
34
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $path ) = @_; |
35
|
|
|
|
|
|
|
my %tags = ( |
36
|
|
|
|
|
|
|
title => $self->{'title'}, |
37
|
0
|
|
|
|
|
0
|
year => $self->{'year'} |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# get the file name |
41
|
0
|
|
|
|
|
0
|
my ( $volume, $directories, $file ) = File::Spec->splitpath($path); |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
0
|
unless ( $tags{title} ) { |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# parse the filename for the title, season and episode |
46
|
0
|
|
|
|
|
0
|
( $tags{title}, $tags{year} ) = $self->_parse_filename($file); |
47
|
0
|
0
|
|
|
|
0
|
unless ( $tags{title} ) { |
48
|
0
|
|
|
|
|
0
|
return "Error: could not parse the filename for $path"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $film = App::MP4Meta::Source::Data::Film->new( |
53
|
|
|
|
|
|
|
genre => $self->{'genre'}, |
54
|
|
|
|
|
|
|
cover => $self->{'cover'}, |
55
|
0
|
|
|
|
|
0
|
year => $self->{'year'}, |
56
|
|
|
|
|
|
|
); |
57
|
0
|
0
|
|
|
|
0
|
unless ( _film_is_complete($film) ) { |
58
|
0
|
|
|
|
|
0
|
for my $source ( @{ $self->{'sources_objects'} } ) { |
|
0
|
|
|
|
|
0
|
|
59
|
|
|
|
|
|
|
say sprintf( "trying source '%s'", $source->name ) |
60
|
0
|
0
|
|
|
|
0
|
if $self->{verbose}; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# merge new epiosde into previous |
63
|
0
|
|
|
|
|
0
|
$film->merge( $source->get_film( \%tags ) ); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# last if we have everything |
66
|
|
|
|
|
|
|
last |
67
|
0
|
0
|
|
|
|
0
|
if ( _film_is_complete($film) ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# check what we have |
72
|
0
|
0
|
|
|
|
0
|
unless ( $film->overview ) { |
73
|
0
|
0
|
0
|
|
|
0
|
if ( $self->{'continue_without_any'} |
74
|
|
|
|
|
|
|
|| $self->{'continue_without_overview'} ) |
75
|
|
|
|
|
|
|
{ |
76
|
0
|
|
|
|
|
0
|
say 'no overview found; continuing'; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
else { |
79
|
0
|
|
|
|
|
0
|
return sprintf( 'no overview found for %s', $tags{title} ); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $apTags = AtomicParsley::Command::Tags->new( |
84
|
|
|
|
|
|
|
title => $film->title, |
85
|
|
|
|
|
|
|
description => $film->overview, |
86
|
|
|
|
|
|
|
longdesc => $film->overview, |
87
|
|
|
|
|
|
|
genre => $film->genre, |
88
|
|
|
|
|
|
|
year => $film->year, |
89
|
|
|
|
|
|
|
artwork => $film->cover, |
90
|
0
|
|
|
|
|
0
|
stik => $self->{'media_type'}, |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
0
|
0
|
|
|
|
0
|
say 'writing tags' if $self->{verbose}; |
94
|
0
|
|
|
|
|
0
|
my $error = $self->_write_tags( $path, $apTags ); |
95
|
0
|
0
|
|
|
|
0
|
return $error if $error; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
0
|
return $self->_add_to_itunes( File::Spec->rel2abs($path) ); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# Parse the filename in order to get the film title. Returns the title. |
101
|
|
|
|
|
|
|
sub _parse_filename { |
102
|
0
|
|
|
0
|
|
0
|
my ( $self, $file ) = @_; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# strip suffix |
105
|
0
|
|
|
|
|
0
|
$file = $self->_strip_suffix($file); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# is there a year? |
108
|
0
|
|
|
|
|
0
|
my $year; |
109
|
0
|
0
|
|
|
|
0
|
if ( $file =~ s/(\d\d\d\d)$// ) { |
110
|
0
|
|
|
|
|
0
|
$year = $1; |
111
|
0
|
|
|
|
|
0
|
chop $file; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
0
|
return ( $self->_clean_title($file), $year ); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# true if we have everything we need in a film |
118
|
|
|
|
|
|
|
sub _film_is_complete { |
119
|
2
|
|
|
2
|
|
5202
|
my $film = shift; |
120
|
2
|
|
33
|
|
|
89
|
return ( $film->overview && $film->genre && $film->year && $film->cover ); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
__END__ |