App-MP4Meta

 view release on metacpan or  search on metacpan

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

    bless( $self, $class );

    # create sources now so they are in scope for as long as we are
    $self->{'sources_objects'} = [];
    for my $source ( @{ $self->{'sources'} } ) {
        try {
            push( @{ $self->{'sources_objects'} },
                $self->_new_source($source) );
        }
        catch {
            say STDERR "could not load source: $_";
        };
    }

    return $self;
}

# Calls AtomicParsley and writes the tags to the file
sub _write_tags {
    my ( $self, $path, $tags ) = @_;

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

    return $title;
}

# adds file to itunes
sub _add_to_itunes {
    my ( $self, $path ) = @_;

    return unless $self->{'itunes'};

    unless ( $^O eq 'darwin' ) {
        say STDERR 'can only add to iTunes on Mac OSX';
        return 1;
    }

    $path =~ s!/!:!g;

    my $cmd = sprintf(
"osascript -e 'tell application \"iTunes\" to add file \"%s\" to playlist \"Library\" of source \"Library\"'",
        $path );

    my $result = `$cmd`;
    if ($?) {
        say STDERR "error adding to iTunes: $result";
        return 1;
    }
    if ( $self->{'verbose'} and $result ) {
        say $result;
    }

    return;
}

# load a module as a new source
sub _new_source {
    my ( $self, $source ) = @_;
    my $module = 'App::MP4Meta::Source::' . $source;
    Module::Load::load($module);

lib/App/MP4Meta/Command/film.pm  view on Meta::CPAN

            sources              => $opt->{sources},
            title                => $opt->{title},
            coverfile            => $opt->{coverfile},
            itunes               => $opt->{itunes},
            verbose              => $opt->{verbose},
            continue_without_any => $opt->{withoutany},
        }
    );

    for my $file (@$args) {
        say "processing $file" if $opt->{verbose};
        my $error;
        try {
            $error = $film->apply_meta($file);
        }
        catch {
            $error = "Error applying meta to $file: $_";
        }
        finally {
            say $error if $error;
        };
    }

    say 'done' if $opt->{verbose};
}

1;

__END__

=pod

=encoding UTF-8

lib/App/MP4Meta/Command/musicvideo.pm  view on Meta::CPAN

            noreplace => $opt->{noreplace},
            genre     => $opt->{genre},
            title     => $opt->{title},
            coverfile => $opt->{coverfile},
            itunes    => $opt->{itunes},
            verbose   => $opt->{verbose},
        }
    );

    for my $file (@$args) {
        say "processing $file" if $opt->{verbose};
        my $error;
        try {
            $error = $mv->apply_meta($file);
        }
        catch {
            $error = "Error applying meta to $file: $_";
        }
        finally {
            say $error if $error;
        };
    }

    say 'done' if $opt->{verbose};
}

1;

__END__

=pod

=encoding UTF-8

lib/App/MP4Meta/Command/tv.pm  view on Meta::CPAN

            genre                => $opt->{genre},
            sources              => $opt->{sources},
            title                => $opt->{title},
            cover                => $opt->{coverfile},
            itunes               => $opt->{itunes},
            verbose              => $opt->{verbose},
            continue_without_any => $opt->{withoutany},
        }
    );

    say sprintf( 'processing %d files', scalar @$args ) if $opt->{verbose};

    for my $file (@$args) {
        say "processing $file" if $opt->{verbose};
        my $error;
        try {
            $error = $tv->apply_meta($file);
        }
        catch {
            $error = "Error applying meta to $file: $_";
        }
        finally {
            say $error if $error;
        };
    }

    say 'done' if $opt->{verbose};
}

1;

__END__

=pod

=encoding UTF-8

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

        }
    }

    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,
        description => $film->overview,
        longdesc    => $film->overview,
        genre       => $film->genre,
        year        => $film->year,
        artwork     => $film->cover,
        stik        => $self->{'media_type'},
    );

    say 'writing tags' if $self->{verbose};
    my $error = $self->_write_tags( $path, $apTags );
    return $error if $error;

    return $self->_add_to_itunes( File::Spec->rel2abs($path) );
}

# Parse the filename in order to get the film title. Returns the title.
sub _parse_filename {
    my ( $self, $file ) = @_;

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

    }

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

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

            # last if we have everything
            last
              if ( _episode_is_complete($episode) );
        }
    }

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

    my $show_title = $episode->show_title // $tags{show_title};
    my $apTags = AtomicParsley::Command::Tags->new(
        artist       => $show_title,

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

        TVEpisodeNum => $tags{episode},
        TVSeasonNum  => $tags{season},
        stik         => $self->{'media_type'},
        description  => $episode->overview,
        longdesc     => $episode->overview,
        genre        => $episode->genre,
        year         => $episode->year,
        artwork      => $episode->cover
    );

    say 'writing tags' if $self->{verbose};
    my $error = $self->_write_tags( $path, $apTags );
    return $error if $error;

    return $self->_add_to_itunes( File::Spec->rel2abs($path) );
}

# Parse the filename in order to get the series title the and season and episode number.
sub _parse_filename {
    my ( $self, $file, $directories ) = @_;



( run in 0.736 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )