App-MP4Meta

 view release on metacpan or  search on metacpan

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

use 5.010;
use strict;
use warnings;

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

# ABSTRACT: Apply metadata to a TV Series. Parses the filename in order to get the shows title and its season and episode number.

use App::MP4Meta -command;

use Try::Tiny;


sub usage_desc { "tv %o [file ...]" }

sub abstract {
'Apply metadata to a TV Series. Parses the filename in order to get the shows title and its season and episode number.';
}

sub opt_spec {
    return (
        [ "genre=s",     "The genre of the TV Show" ],
        [ "coverfile=s", "The location of the cover image" ],
        [ "sources=s@", "The sources to search", { default => [qw/TVDB/] } ],
        [ "title=s",   "The title of the TV Show" ],
        [ "series=s",  "The series number" ],
        [ "episode=s", "The episode number" ],
        [ "noreplace", "Don't replace the file - creates a temp file instead" ],
        [ "itunes",  "adds to iTunes after applying meta data. Mac OSX only." ],
        [ "verbose", "Print verbosely" ],
        [
            "withoutany",
"Continue to process even if we can not find any information on the internet"
        ],
    );
}

sub validate_args {
    my ( $self, $opt, $args ) = @_;

    # we need at least one file to work with
    $self->usage_error("too few arguments") unless @$args;

    # TODO: check we have a source

    # check each file
    for my $f (@$args) {
        unless ( -e $f ) {
            $self->usage_error("$f does not exist");
        }
        unless ( -r $f ) {
            $self->usage_error("can not read $f");
        }

        # TODO: is $f an mp4?
    }
}

sub execute {
    my ( $self, $opt, $args ) = @_;

    require App::MP4Meta::TV;
    my $tv = App::MP4Meta::TV->new(
        {
            noreplace            => $opt->{noreplace},
            genre                => $opt->{genre},
            sources              => $opt->{sources},
            title                => $opt->{title},
            cover                => $opt->{coverfile},
            itunes               => $opt->{itunes},
            verbose              => $opt->{verbose},



( run in 1.384 second using v1.01-cache-2.11-cpan-39bf76dae61 )