MP4Meta/Command/film.pm

filter: Statementstmt 44.7% 17 / 38 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 38.4% 5 / 13 Podpod 100% 5 / 5 totaltotal 39.7% 27 / 68 CC 9 SCAR 25.0
CC
9
Cov
34%
validate_args
30.0
execute
20.0
__ANON__
6.0
CRAP 12.2
« MP4Meta/Command/tv.pm ↑ Summary MP4Meta/Command/musicvideo.pm »
1 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package App::MP4Meta::Command::film;
6 {
7 1 $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 ▶use App::MP4Meta -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16  
17 0 ▶sub usage_desc { "film %o [file ...]" }
Subroutine usage_desc: not called CC=1 SCAR=6.9
Pod documented
18  
19 0 ▶sub abstract {
Subroutine abstract: not called CC=1 SCAR=6.9
Pod documented
20 0 'Apply metadata to a film. Parses the filename in order to get the films title and (optionally) year.';
21 }
22  
23 0 ▶sub opt_spec {
Subroutine opt_spec: not called CC=1 SCAR=6.9
Pod documented
24 return (
25 0 [ "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 0 ▶sub validate_args {
Subroutine validate_args: not called CC=5 SCAR=34.0
Pod documented
40 0 my ( $self, $opt, $args ) = @_;
41  
42 # we need at least one file to work with
43 0 ▶ $self->usage_error("too few arguments") unless @$args;
Branch: 1 branch
BranchTrueFalseTotal
unless @$args 0 0 0
44  
45 # check each file
46 0 for my $f (@$args) {
47 0 ▶ unless ( -e $f ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $f) 0 0 0
48 0 $self->usage_error("$f does not exist");
49 }
50 0 ▶ unless ( -r $f ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-r $f) 0 0 0
51 0 $self->usage_error("can not read $f");
52 }
53  
54 # TODO: is $f an mp4?
55 }
56 }
57  
58 0 ▶sub execute {
Subroutine execute: not called CC=4 SCAR=30.0
Pod documented
59 0 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 ▶ say "processing $file" if $opt->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $opt->{"verbose"} 0 0 0
77 0 my $error;
78 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
79 0 $error = $film->apply_meta($file);
80 }
81 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
82 0 $error = "Error applying meta to $file: $_";
83 }
84 0 ▶ finally {
Subroutine __ANON__: not called CC=2 SCAR=17.9
85 0 ▶ say $error if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 0 0
86 0 };
87 }
88  
89 0 ▶ say 'done' if $opt->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $opt->{"verbose"} 0 0 0
90 }
91  
92 1 1;
93  
94 __END__
« MP4Meta/Command/tv.pm ↑ Summary MP4Meta/Command/musicvideo.pm »