Please find attached three diffs for files in this distribution; with these improvements and fixes I am actually able to get album infos from FreeDB and do some useful things with it. I could apply and release a new version if you'd give me co-maintainer privileges for MP3-Album.
Cheers,
Marek (marekr@cpan.org)
--- C:\Strawberry\perl\site\lib\MP3\Album.pm Mon Aug 4 17:46:09 2003
+++ lib\MP3\Album.pm Sat Jan 2 14:09:03 2016
@@ -7,7 +7,7 @@
use MP3::Album::Layout;
use File::Basename;
-our $VERSION = '0.14';
+our $VERSION = '0.15';
sub new {
my $c = shift;
@@ -109,7 +109,7 @@
bitrates => [ $s->_album_bitrate() ],
uniform_bitrate => scalar($s->_album_bitrate()) == 1 ? 1 : 0,
frequencies => [ $s->_album_frequencies() ],
- uniform_frequency => scalar($s->_album_frequency()) == 1 ? 1 : 0,
+ uniform_frequency => scalar($s->_album_frequencies()) == 1 ? 1 : 0,
cddb_disc_id => $s->{cddb_query}->{discid}
);
return wantarray ? %info : \%info;
--- C:\Strawberry\perl\site\lib\MP3\Album\Layout\Fetcher\CDDB.pm Mon Jul 14 17:40:37 2003
+++ lib\MP3\Album\Layout\Fetcher\CDDB.pm Sat Jan 2 14:12:46 2016
@@ -5,6 +5,8 @@
use CDDB;
use Data::Dumper;
+our $VERSION = '0.02';
+
sub fetch {
my $c = shift;
my %a = @_;
@@ -33,15 +35,26 @@
foreach my $disc (@cddb_discs) {
my $disc_info = $cddb->get_disc_details($disc->[0], $disc->[1]);
last unless $disc_info;
- my ($artist,$title) = split(/\s*\/\s*/, $disc->[2]);
+#warn "DEBUG: CDDB returned disc info: ".Dumper($disc_info);
+# CDDB has:
+# offsets[], submitted via, genre, ttitles[], seconds[], disc length, revision,
+# discid, xmcd_record, processed by, dgenre, dtitle, dyear, extd
+
+ my ($artist,$title) = split(/\s+\/\s+/,
+ $disc_info->{dtitle} || $disc->[2],2);
my $layout = MP3::Album::Layout->new();
- $layout->artist($artist);
$layout->title($title);
- $layout->genre($disc->[0]);
+ $layout->artist($artist);
+ $layout->genre($disc_info->{dgenre} || $disc_info->{genre} || $disc->[0]);
+ $layout->year($disc_info->{dyear}) if $disc_info->{dyear};
+ $layout->comment($disc_info->{extd}) if $disc_info->{extd};
+ if($disc_info->{xmcd_record}) {
+ }
+
my $k = 0;
foreach my $t (@{$disc_info->{ttitles}}) {
- $layout->add_track( title => $t, artist => $artist, lenght=> $disc_info->{seconds}->[$k]);
+ $layout->add_track( title => $t, artist => $artist, 'length' => $disc_info->{seconds}->[$k]);
$k++;
}
push @results, $layout;
--- C:\Strawberry\perl\site\lib\MP3\Album\Layout.pm Thu Mar 20 17:11:47 2003
+++ lib\MP3\Album\Layout.pm Sat Jan 2 14:08:39 2016
@@ -2,7 +2,7 @@
use strict;
-our $VERSION = '0.01';
+our $VERSION = '0.02';
sub new {
my $s = shift;
@@ -51,7 +51,7 @@
push @{$s->{tracks}}, { 'artist' => $a{artist},
'title' => $a{title},
- 'lenght' => $a{lenght}
+ 'length' => $a{'length'}
};
return 1;
@@ -84,4 +84,22 @@
return $s->{title};
}
+
+sub year {
+ my $s = shift;
+ $s->{year} = $_[0] if @_;
+
+ return $s->{year};
+}
+
+sub tracks {
+ my $s = shift;
+
+ if(wantarray()) {
+ return @{$s->{tracks}};
+ } else {
+ return $s->{tracks};
+ }
+}
+
1;