App-MP4Meta

 view release on metacpan or  search on metacpan

lib/App/MP4Meta/Film.pm  view on Meta::CPAN

use 5.010;
use strict;
use warnings;

package App::MP4Meta::Film;
{
  $App::MP4Meta::Film::VERSION = '1.153340';
}

# ABSTRACT: Add metadata to a film

use App::MP4Meta::Base;
our @ISA = 'App::MP4Meta::Base';

use File::Spec '3.33';
use AtomicParsley::Command::Tags;

use App::MP4Meta::Source::Data::Film;

sub new {
    my $class = shift;
    my $args  = shift;

    my $self = $class->SUPER::new($args);

    # Of course, its a movie, but this fixes the
    # 'Home Video' problem in iTunes 11.
    $self->{'media_type'} = 'Short Film';

    return $self;
}

sub apply_meta {
    my ( $self, $path ) = @_;
    my %tags = (
        title => $self->{'title'},
        year  => $self->{'year'}
    );

    # get the file name
    my ( $volume, $directories, $file ) = File::Spec->splitpath($path);

    unless ( $tags{title} ) {

        # parse the filename for the title, season and episode
        ( $tags{title}, $tags{year} ) = $self->_parse_filename($file);
        unless ( $tags{title} ) {
            return "Error: could not parse the filename for $path";
        }
    }

    my $film = App::MP4Meta::Source::Data::Film->new(
        genre => $self->{'genre'},
        cover => $self->{'cover'},
        year  => $self->{'year'},
    );
    unless ( _film_is_complete($film) ) {
        for my $source ( @{ $self->{'sources_objects'} } ) {
            say sprintf( "trying source '%s'", $source->name )
              if $self->{verbose};

            # merge new epiosde into previous
            $film->merge( $source->get_film( \%tags ) );

            # last if we have everything
            last
              if ( _film_is_complete($film) );
        }
    }

    # check what we have
    unless ( $film->overview ) {
        if (   $self->{'continue_without_any'}
            || $self->{'continue_without_overview'} )
        {
            say 'no overview found; continuing';
        }
        else {
            return sprintf( 'no overview found for %s', $tags{title} );
        }
    }

    my $apTags = AtomicParsley::Command::Tags->new(
        title       => $film->title,



( run in 1.728 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )