| 1 | 2 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package App::MP4Meta::Film; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | $App::MP4Meta::Film::VERSION = '1.153340'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # ABSTRACT: Add metadata to a film | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use App::MP4Meta::Base; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | our @ISA = 'App::MP4Meta::Base'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use File::Spec '3.33'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use AtomicParsley::Command::Tags; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use App::MP4Meta::Source::Data::Film; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | 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 | $self->{'media_type'} = 'Short Film'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub apply_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_meta: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my ( $self, $path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | my %tags = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | title => $self->{'title'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | year => $self->{'year'} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # get the file name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my ( $volume, $directories, $file ) = File::Spec->splitpath($path); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | unless ( $tags{title} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # parse the filename for the title, season and episode | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ( $tags{title}, $tags{year} ) = $self->_parse_filename($file); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | unless ( $tags{title} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 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 | year => $self->{'year'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | unless ( _film_is_complete($film) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | for my $source ( @{ $self->{'sources_objects'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | say sprintf( "trying source '%s'", $source->name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # merge new epiosde into previous | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $film->merge( $source->get_film( \%tags ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # last if we have everything | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | last | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ( _film_is_complete($film) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # check what we have | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | unless ( $film->overview ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ( $self->{'continue_without_any'} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"continue_without_any"} or $self->{"continue_without_overview"}
MC/DC0%0/2
$self->{"continue_without_any"} or $self->{"continue_without_overview"}
$self->{"continue_without_any"}
$self->{"continue_without_overview"}
Truth table0%0/3
A or B
A= $self->{"continue_without_any"}B= $self->{"continue_without_overview"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | || $self->{'continue_without_overview'} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | say 'no overview found; continuing'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 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 | stik => $self->{'media_type'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | say 'writing tags' if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $error = $self->_write_tags( $path, $apTags ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | return $error if $error; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 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 | 0 | ▶ | sub _parse_filename { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_filename: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # strip suffix | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $file = $self->_strip_suffix($file); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # is there a year? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $year; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ( $file =~ s/(\d\d\d\d)$// ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $year = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | chop $file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | return ( $self->_clean_title($file), $year ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # true if we have everything we need in a film | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | sub _film_is_complete { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_film_is_complete: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $film = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | return ( $film->overview && $film->genre && $film->year && $film->cover ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$film->overview && $film->genre && $film->year && $film->cover
$film->overview and $film->genre and $film->year
$film->overview and $film->genre
MC/DC0%0/4
$film->overview && $film->genre && $film->year && $film->cover
$film->overview
$film->genre
$film->year
$film->cover
Truth table0%0/5
A and B and C && D
A= $film->overviewB= $film->genreC= $film->yearD= $film->cover
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||