line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
12281
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
69
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package App::MP4Meta::Command::film; |
6
|
|
|
|
|
|
|
{ |
7
|
|
|
|
|
|
|
$App::MP4Meta::Command::film::VERSION = '1.153340'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Apply metadata to a film. Parses the filename in order to get the films title and (optionally) year. |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use App::MP4Meta -command; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
363
|
use Try::Tiny; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
515
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
1
|
39419
|
sub usage_desc { "film %o [file ...]" } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub abstract { |
20
|
0
|
|
|
0
|
1
|
0
|
'Apply metadata to a film. Parses the filename in order to get the films title and (optionally) year.'; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub opt_spec { |
24
|
|
|
|
|
|
|
return ( |
25
|
2
|
|
|
2
|
1
|
28
|
[ "genre=s", "The genre of the Film" ], |
26
|
|
|
|
|
|
|
[ "coverfile=s", "The location of the cover image" ], |
27
|
|
|
|
|
|
|
[ "sources=s@", "The sources to search", { default => [qw/OMDB/] } ], |
28
|
|
|
|
|
|
|
[ "title=s", "The title of the Film" ], |
29
|
|
|
|
|
|
|
[ "noreplace", "Don't replace the file - creates a temp file instead" ], |
30
|
|
|
|
|
|
|
[ "itunes", "adds to iTunes after applying meta data. Mac OSX only." ], |
31
|
|
|
|
|
|
|
[ "verbose", "Print verbosely" ], |
32
|
|
|
|
|
|
|
[ |
33
|
|
|
|
|
|
|
"withoutany", |
34
|
|
|
|
|
|
|
"Continue to process even if we can not find any information on the internet" |
35
|
|
|
|
|
|
|
], |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub validate_args { |
40
|
2
|
|
|
2
|
1
|
3483
|
my ( $self, $opt, $args ) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# we need at least one file to work with |
43
|
2
|
100
|
|
|
|
17
|
$self->usage_error("too few arguments") unless @$args; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# check each file |
46
|
1
|
|
|
|
|
3
|
for my $f (@$args) { |
47
|
1
|
50
|
|
|
|
178
|
unless ( -e $f ) { |
48
|
1
|
|
|
|
|
6
|
$self->usage_error("$f does not exist"); |
49
|
|
|
|
|
|
|
} |
50
|
0
|
0
|
|
|
|
|
unless ( -r $f ) { |
51
|
0
|
|
|
|
|
|
$self->usage_error("can not read $f"); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# TODO: is $f an mp4? |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub execute { |
59
|
0
|
|
|
0
|
1
|
|
my ( $self, $opt, $args ) = @_; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
require App::MP4Meta::Film; |
62
|
|
|
|
|
|
|
my $film = App::MP4Meta::Film->new( |
63
|
|
|
|
|
|
|
{ |
64
|
|
|
|
|
|
|
noreplace => $opt->{noreplace}, |
65
|
|
|
|
|
|
|
genre => $opt->{genre}, |
66
|
|
|
|
|
|
|
sources => $opt->{sources}, |
67
|
|
|
|
|
|
|
title => $opt->{title}, |
68
|
|
|
|
|
|
|
coverfile => $opt->{coverfile}, |
69
|
|
|
|
|
|
|
itunes => $opt->{itunes}, |
70
|
|
|
|
|
|
|
verbose => $opt->{verbose}, |
71
|
|
|
|
|
|
|
continue_without_any => $opt->{withoutany}, |
72
|
|
|
|
|
|
|
} |
73
|
0
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
for my $file (@$args) { |
76
|
0
|
0
|
|
|
|
|
say "processing $file" if $opt->{verbose}; |
77
|
0
|
|
|
|
|
|
my $error; |
78
|
|
|
|
|
|
|
try { |
79
|
0
|
|
|
0
|
|
|
$error = $film->apply_meta($file); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
catch { |
82
|
0
|
|
|
0
|
|
|
$error = "Error applying meta to $file: $_"; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
finally { |
85
|
0
|
0
|
|
0
|
|
|
say $error if $error; |
86
|
0
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
say 'done' if $opt->{verbose}; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |