| 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::musicvideo; | ||||||||||
| 6 | { | ||||||||||
| 7 | 1 | $App::MP4Meta::Command::musicvideo::VERSION = '1.153340'; | |||||||||
| 8 | } | ||||||||||
| 9 | |||||||||||
| 10 | # ABSTRACT: Apply metadata to a music video. Parses the filename in order to get its artist and title. | ||||||||||
| 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 { "musicvideo %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 music video. Parses the filename in order to get its artist and title.'; | |||||||||
| 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 music video" ], | |||||||||
| 26 | [ "coverfile=s", "The location of the cover image" ], | ||||||||||
| 27 | [ "title=s", "The title of the music video" ], | ||||||||||
| 28 | [ "noreplace", "Don't replace the file - creates a temp file instead" ], | ||||||||||
| 29 | [ "itunes", "adds to iTunes after applying meta data. Mac OSX only." ], | ||||||||||
| 30 | [ "verbose", "Print verbosely" ], | ||||||||||
| 31 | ); | ||||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | sub validate_args { | ||||||||
|
Subroutine
validate_args: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 35 | 0 | my ( $self, $opt, $args ) = @_; | |||||||||
| 36 | |||||||||||
| 37 | # we need at least one file to work with | ||||||||||
| 38 | 0 | ▶ | $self->usage_error("too few arguments") unless @$args; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | |||||||||||
| 40 | # check each file | ||||||||||
| 41 | 0 | for my $f (@$args) { | |||||||||
| 42 | 0 | ▶ | unless ( -e $f ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | $self->usage_error("$f does not exist"); | |||||||||
| 44 | } | ||||||||||
| 45 | 0 | ▶ | unless ( -r $f ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 0 | $self->usage_error("can not read $f"); | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | # TODO: is $f an mp4? | ||||||||||
| 50 | } | ||||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 0 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 54 | 0 | my ( $self, $opt, $args ) = @_; | |||||||||
| 55 | |||||||||||
| 56 | 0 | require App::MP4Meta::MusicVideo; | |||||||||
| 57 | my $mv = App::MP4Meta::MusicVideo->new( | ||||||||||
| 58 | { | ||||||||||
| 59 | noreplace => $opt->{noreplace}, | ||||||||||
| 60 | genre => $opt->{genre}, | ||||||||||
| 61 | title => $opt->{title}, | ||||||||||
| 62 | coverfile => $opt->{coverfile}, | ||||||||||
| 63 | itunes => $opt->{itunes}, | ||||||||||
| 64 | verbose => $opt->{verbose}, | ||||||||||
| 65 | } | ||||||||||
| 66 | 0 | ); | |||||||||
| 67 | |||||||||||
| 68 | 0 | for my $file (@$args) { | |||||||||
| 69 | 0 | ▶ | say "processing $file" if $opt->{verbose}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | 0 | my $error; | |||||||||
| 71 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 72 | 0 | $error = $mv->apply_meta($file); | |||||||||
| 73 | } | ||||||||||
| 74 | 0 | ▶ | catch { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 75 | 0 | $error = "Error applying meta to $file: $_"; | |||||||||
| 76 | } | ||||||||||
| 77 | 0 | ▶ | finally { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 78 | 0 | ▶ | say $error if $error; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 79 | 0 | }; | |||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | 0 | ▶ | say 'done' if $opt->{verbose}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | 1 | 1; | |||||||||
| 86 | |||||||||||
| 87 | __END__ | ||||||||||