MP3-Tag-Utils

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

use strict;
use warnings;
use ExtUtils::MakeMaker;

WriteMakefile(
			  NAME                => 'MP3::Tag::Utils',
			  AUTHOR              => q{Zane C. Bowers <vvelox@vvelox.net>},
			  VERSION_FROM        => 'lib/MP3/Tag/Utils.pm',
			  ABSTRACT_FROM       => 'lib/MP3/Tag/Utils.pm',
			  ($ExtUtils::MakeMaker::VERSION >= 6.3002
			   ? ('LICENSE'=> 'perl')
			   : ()),
			  PL_FILES            => {},
			  INST_SCRIPT => 'bin',
			  PREREQ_PM => {
							'Test::More' => 0,
							'MP3::Tag'=>0,
							'Text::NeatTemplate'=>0,
							},
			  dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
			  clean               => { FILES => 'MP3-Tag-Utils-*' },
			  );

README  view on Meta::CPAN

MP3-Tag-Utils

Some assorted useful utilities for using MP3::Tag.


INSTALLATION

To install this module, run the following commands:

	perl Makefile.PL
	make
	make test
	make install

SUPPORT AND DOCUMENTATION

After installing, you can find documentation for this module with the
perldoc command.

    perldoc MP3::Tag::Utils

You can also look for information at:

    RT, CPAN's request tracker
        http://rt.cpan.org/NoAuth/Bugs.html?Dist=MP3-Tag-Utils

    AnnoCPAN, Annotated CPAN documentation
        http://annocpan.org/dist/MP3-Tag-Utils

    CPAN Ratings

bin/mp3rename  view on Meta::CPAN

#INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
#LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
#THE POSSIBILITY OF SUCH DAMAGE.

use strict;
use warnings;
use Getopt::Std;
use MP3::Tag::Utils;

#version function
sub main::VERSION_MESSAGE {
        print "mp3rename 0.0.0\n";
}

#print help
sub main::HELP_MESSAGE {
        print "\n".
		      "-t <template>  The template to use.\n".
			  "-p <pad to>  The number of zeros to track should be padded out to.\n";
}

#gets the options
my %opts;
getopts('t:p:', \%opts);

#
my $mp3util=MP3::Tag::Utils->new;

my $returned=$mp3util->rename({files=>\@ARGV, template=>$opts{t}, padto=>$opts{p}});

#exit if the module errored
if ($mp3util->error) {
	exit $mp3util->error;
}

#errors if it failed
if (! $returned->{success}) {

bin/mp3rename  view on Meta::CPAN

=head1 SWTICHES

=head2 -p <padto>

This is the number of zeros to pad the track number out to. By default this is 2.

=head2 -t <template>

This is the remplate to use for the new file name.

For more information on this see MP3::Tag::Utils.

=head1 AUTHOR

Copyright (c) 2010, Zame C. Bowers <vvelox@vvelox.net>

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

bin/mp3show  view on Meta::CPAN

#INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
#LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
#THE POSSIBILITY OF SUCH DAMAGE.

use strict;
use warnings;
use Getopt::Std;
use MP3::Tag::Utils;

#version function
sub main::VERSION_MESSAGE {
        print "mp3show 0.0.1\n";
}

#print help
sub main::HELP_MESSAGE {
}

#gets the options
my %opts;
getopts('', \%opts);

#
my $mp3util=MP3::Tag::Utils->new;

my $returned=$mp3util->show({files=>\@ARGV, });

#exit if the module errored
if ($mp3util->error) {
	exit $mp3util->error;
}

#errors if it failed
if (! $returned->{success}) {

bin/mp3tag  view on Meta::CPAN

#INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
#LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
#THE POSSIBILITY OF SUCH DAMAGE.

use strict;
use warnings;
use Getopt::Std;
use MP3::Tag::Utils;

$Getopt::Std::STANDARD_HELP_VERSION = 1;

#version function
sub main::VERSION_MESSAGE {
        print "mp3tag 0.0.0\n";
}

#print help
sub main::HELP_MESSAGE {

bin/mp3tag  view on Meta::CPAN

if (
	defined( $ARGV[1] ) &&
	(!defined( $opts{S} )) &&
	(defined($opts{t}))
	) {
	warn('More than one file specified and "-t" is being used, but "-S" is not supplied');
	exit 254;
}

#init the utility
my $mp3util=MP3::Tag::Utils->new;

#change each one
my $int=0;
while ($ARGV[$int]) {
	$mp3util->change({
					  file=>$ARGV[$int],
					  album=>$opts{a},
					  artist=>$opts{A},
					  comment=>$opts{c},
					  genre=>$opts{g},

lib/MP3/Tag/Utils.pm  view on Meta::CPAN

package MP3::Tag::Utils;

use warnings;
use strict;
use MP3::Tag;
use Text::NeatTemplate;

=head1 NAME

MP3::Tag::Utils - Assorted utilities for manipulating MP3 files via MP3::Tag.

=head1 VERSION

Version 0.0.3

=cut

our $VERSION = '0.0.3';


=head1 SYNOPSIS

    use MP3::Tag::Utils;

    my $foo = MP3::Tag::Utils->new();
    ...

=head1 METHODS

=head2 new

=cut

sub new{
	my %args;

lib/MP3/Tag/Utils.pm  view on Meta::CPAN

	if (
		defined($args{year}) &&
		($args{year} !~ /^[0123456789]*$/)
		) {
		$self->{error}=5;
		$self->{errorString}='Track is not numeric';
		warn($self->{module}.' '.$method.':'.$self->error.': '.$self->{errorString});
		return undef;		
	}

	my $mp3=MP3::Tag->new($args{file});

	delete($args{file});

	$mp3->update_tags(\%args);

	return 1;
}

=head2 rename

lib/MP3/Tag/Utils.pm  view on Meta::CPAN

	my $int=0;
	while (defined( $args{files}[$int] )) {

		if (
			(! -r $args{files}[$int] ) ||
			( $args{files}[$int] !~ /\.[Mm][Pp]3$/ )
			) {
			$toreturn->{success}=0;
			push( @{ $self->{failed} }, $args{file}[$int] );
		}else {
			my $mp3=MP3::Tag->new( $args{files}[$int] );
			my ($title, $track, $artist, $album, $comment, $year, $genre) = $mp3->autoinfo();

			my $int2=length($track);
			while ($int2 < $args{padto}) {
				$track='0'.$track;

				$int2++;
			}

			$track=~s/\/.*//;

lib/MP3/Tag/Utils.pm  view on Meta::CPAN

	my $int=0;
	while (defined( $args{files}[$int] )) {

		if (
			(! -r $args{files}[$int] ) ||
			( $args{files}[$int] !~ /\.[Mm][Pp]3$/ )
			) {
			$toreturn->{success}=0;
			push( @{ $self->{failed} }, $args{file}[$int] );
		}else {
			my $mp3=MP3::Tag->new( $args{files}[$int] );
			my ($title, $track, $artist, $album, $comment, $year, $genre) = $mp3->autoinfo();

			my $int2=length($track);
			while ($int2 < $args{padto}) {
				$track='0'.$track;

				$int2++;
			}

			$track=~s/\/.*//;

lib/MP3/Tag/Utils.pm  view on Meta::CPAN

the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MP3-Tag-Utils>.  I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.




=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc MP3::Tag::Utils


You can also look for information at:

=over 4

=item * RT: CPAN's request tracker

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=MP3-Tag-Utils>

lib/MP3/Tag/Utils.pm  view on Meta::CPAN


This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.


=cut

1; # End of MP3::Tag::Utils

t/00-load.t  view on Meta::CPAN

#!perl -T

use Test::More tests => 1;

BEGIN {
    use_ok( 'MP3::Tag::Utils' ) || print "Bail out!
";
}

diag( "Testing MP3::Tag::Utils $MP3::Tag::Utils::VERSION, Perl $], $^X" );



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