Initial commit 0.000_001
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 29 Nov 2014 23:03:32 +0000 (01:03 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 29 Nov 2014 23:03:32 +0000 (01:03 +0200)
Changes [new file with mode: 0644]
MANIFEST [new file with mode: 0644]
Makefile.PL [new file with mode: 0644]
README [new file with mode: 0644]
lib/Music/Tag/Coveralia.pm [new file with mode: 0644]
t/Music-Tag-Coveralia.t [new file with mode: 0644]
t/empty.flac [new file with mode: 0644]
t/perlcritic.t [new file with mode: 0644]
t/perlcriticrc [new file with mode: 0644]

diff --git a/Changes b/Changes
new file mode 100644 (file)
index 0000000..e905e7a
--- /dev/null
+++ b/Changes
@@ -0,0 +1,4 @@
+Revision history for Perl extension Music::Tag::Coveralia.
+
+0.000_001 2014-10-30T01:02+02:00
+ - Initial release
diff --git a/MANIFEST b/MANIFEST
new file mode 100644 (file)
index 0000000..97d6da8
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,9 @@
+Changes
+Makefile.PL
+MANIFEST
+README
+t/Music-Tag-Coveralia.t
+t/empty.flac
+t/perlcritic.t
+t/perlcriticrc
+lib/Music/Tag/Coveralia.pm
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644 (file)
index 0000000..e26f950
--- /dev/null
@@ -0,0 +1,28 @@
+use 5.014000;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+       NAME              => 'Music::Tag::Coveralia',
+       VERSION_FROM      => 'lib/Music/Tag/Coveralia.pm',
+       ABSTRACT_FROM     => 'lib/Music/Tag/Coveralia.pm',
+       AUTHOR            => 'Marius Gavrilescu <marius@ieval.ro>',
+       MIN_PERL_VERSION  => '5.14.0',
+       LICENSE           => 'perl',
+       BUILD_REQUIRES    => {
+               qw/Test::RequiresInternet 0/,
+       },
+       SIGN              => 1,
+       PREREQ_PM         => {
+               qw/Music::Tag 0
+                  Music::Tag::Generic 0
+                  LWP::Simple 0
+                  WWW::Search 0
+                  WWW::Search::Coveralia 0/,
+       },
+       META_ADD         => {
+               dynamic_config => 0,
+               resources      => {
+                       repository   => 'http://git.ieval.ro/?p=music-tag-coveralia.git',
+               },
+       }
+);
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..f56e504
--- /dev/null
+++ b/README
@@ -0,0 +1,29 @@
+Music-Tag-Coveralia version 0.000_001
+=====================================
+
+INSTALLATION
+
+To install this module type the following:
+
+   perl Makefile.PL
+   make
+   make test
+   make install
+
+DEPENDENCIES
+
+This module requires these other modules and libraries:
+
+* Music::Tag
+* WWW::Search
+* WWW::Search::Coveralia
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2014 by Marius Gavrilescu
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.20.1 or,
+at your option, any later version of Perl 5 you may have available.
+
+
diff --git a/lib/Music/Tag/Coveralia.pm b/lib/Music/Tag/Coveralia.pm
new file mode 100644 (file)
index 0000000..6a23335
--- /dev/null
@@ -0,0 +1,102 @@
+package Music::Tag::Coveralia;
+
+use 5.014000;
+use strict;
+use warnings;
+use parent qw/Music::Tag::Generic/;
+
+our $VERSION = '0.000_001';
+
+use LWP::Simple qw/get/;
+use WWW::Search;
+
+sub required_values { qw/album/ }
+sub set_values { qw/picture/ }
+
+sub get_tag {
+       my ($self) = @_;
+
+       my $album = $self->info->get_data('album');
+       my $ws = WWW::Search->new('Coveralia::Albums');
+       $self->status(1, "Searching coveralia for the album $album");
+       $ws->native_query(WWW::Search::escape_query($album));
+       while (my $res = $ws->next_result) {
+               $self->status(1, 'Found album ' . $res->title . ' by ' . $res->artist);
+               next if $self->info->has_data('artist') && $self->info->get_data('artist') ne $res->artist;
+               $self->status(0, 'Selected album ' . $res->title . ' by ' . $res->artist);
+               if ($res->cover('frontal')) {
+                       $self->info->set_data(picture => {_Data => get $res->cover('frontal')});
+                       $self->tagchange('picture');
+               }
+               last
+       }
+
+       return $self->info
+}
+
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+Music::Tag::Coveralia - Get cover art from coveralia.com
+
+=head1 SYNOPSIS
+
+  use Music::Tag;
+  my $mt = Music::Tag->new($filename);
+  $mt->add_plugin('Coveralia');
+  $mt->get_tag;
+
+=head1 DESCRIPTION
+
+This plugin gets cover art from L<http://coveralia.com>, based on album and (optionally) artist.
+
+=head1 REQUIRED DATA VALUES
+
+=over
+
+=item album
+
+Used as the search term.
+
+=back
+
+=head1 USED DATA VALUES
+
+=over
+
+=item artist
+
+If present, the first album found from this artist is chosen. Otherwise the first album found is chosen.
+
+=back
+
+=head1 SET DATA VALUES
+
+=over
+
+=item picture
+
+=back
+
+=head1 SEE ALSO
+
+L<Music::Tag>, L<WWW::Search::Coveralia>, L<http://coveralia.com>
+
+=head1 AUTHOR
+
+Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2014 by Marius Gavrilescu
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.20.1 or,
+at your option, any later version of Perl 5 you may have available.
+
+
+=cut
diff --git a/t/Music-Tag-Coveralia.t b/t/Music-Tag-Coveralia.t
new file mode 100644 (file)
index 0000000..38c5efc
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Test::RequiresInternet qw/www.coveralia.com 80/;
+use Test::More tests => 3;
+use Music::Tag traditional => 1;
+BEGIN { use_ok('Music::Tag::Coveralia') };
+
+sub test {
+       my ($artist, $album, $expect) = @_;
+       my $mt = Music::Tag->new('t/empty.flac', {$ENV{TEST_VERBOSE} ? (verbose => 1) : (quiet => 1)});
+       $mt->artist($artist);
+       $mt->album($album);
+       $mt->add_plugin('Coveralia');
+       $mt->get_tag;
+       my $exists = $expect ? 'exists' : 'does not exist';
+       is $mt->has_data('picture'), $expect, "$artist - $album $exists"
+}
+
+test 'Metallica', 'Ride The Lightning', 1;
+test 'Metal', 'Ride The Lightning', 0;
diff --git a/t/empty.flac b/t/empty.flac
new file mode 100644 (file)
index 0000000..fcac9d9
Binary files /dev/null and b/t/empty.flac differ
diff --git a/t/perlcritic.t b/t/perlcritic.t
new file mode 100644 (file)
index 0000000..51bad9d
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/perl
+use v5.14;
+use warnings;
+
+use Test::More;
+
+BEGIN { plan skip_all => '$ENV{RELEASE_TESTING} is false' unless $ENV{RELEASE_TESTING} }
+use Test::Perl::Critic -profile => 't/perlcriticrc';
+
+all_critic_ok
diff --git a/t/perlcriticrc b/t/perlcriticrc
new file mode 100644 (file)
index 0000000..5973bef
--- /dev/null
@@ -0,0 +1,29 @@
+severity = 1
+
+[-CodeLayout::RequireTidyCode]
+[-ControlStructures::ProhibitPostfixControls]
+[-ControlStructures::ProhibitUnlessBlocks]
+[-Documentation::PodSpelling]
+[-Documentation::RequirePodLinksIncludeText]
+[-InputOutput::RequireBracedFileHandleWithPrint]
+[-RegularExpressions::ProhibitEnumeratedClasses]
+[-RegularExpressions::RequireLineBoundaryMatching]
+[-Subroutines::RequireFinalReturn]
+[-ValuesAndExpressions::ProhibitConstantPragma]
+[-ValuesAndExpressions::ProhibitEmptyQuotes]
+[-ValuesAndExpressions::ProhibitMagicNumbers]
+[-ValuesAndExpressions::ProhibitNoisyQuotes]
+[-Variables::ProhibitLocalVars]
+[-Variables::ProhibitPackageVars]
+[-Variables::ProhibitPunctuationVars]
+
+[RegularExpressions::RequireExtendedFormatting]
+minimum_regex_length_to_complain_about = 20
+
+[Documentation::RequirePodSections]
+lib_sections = NAME | SYNOPSIS | DESCRIPTION | AUTHOR | COPYRIGHT AND LICENSE
+script_sections = NAME | SYNOPSIS | DESCRIPTION | AUTHOR | COPYRIGHT AND LICENSE
+
+[Subroutines::RequireArgUnpacking]
+short_subroutine_statements = 5
+allow_subscripts = 1
This page took 0.018937 seconds and 4 git commands to generate.