1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
Description: libaudio-file-perl: Should be able to handle disc number tags
Author: Alex Malinovich <demonbane@the-love-shack.net>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=337338
--- a/lib/Audio/File/Flac/Tag.pm
+++ b/lib/Audio/File/Flac/Tag.pm
@@ -19,6 +19,7 @@
$self->genre( $flactag->{GENRE} );
$self->year( $flactag->{DATE} );
$self->track( $flactag->{TRACKNUMBER} );
+ $self->disc( $flactag->{DISCNUMBER} );
$self->total( $flactag->{TRACKTOTAL} );
return 1;
--- a/lib/Audio/File/Mp3/Tag.pm
+++ b/lib/Audio/File/Mp3/Tag.pm
@@ -25,6 +25,25 @@
$self->track ( substr($track, 0, $pos) );
$self->total ( substr($track, $pos + 1) );
+ if (exists $self->{mp3}->{ID3v2}) {
+ my $disctag = 0;
+ if ($self->{mp3}->{ID3v2}->get_frame("TPA")) {
+ $disctag = $self->{mp3}->{ID3v2}->get_frame("TPA");
+ }elsif ($self->{mp3}->{ID3v2}->get_frame("TPOS")) {
+ $disctag = $self->{mp3}->{ID3v2}->get_frame("TPOS");
+ }else {
+ return 1;
+ }
+ my $disctotal = 0;
+ my $disc = 0;
+ if ($disctag =~ /\//) {
+ ($disc, $disctotal) = split(/\//,$disctag,2);
+ }else {
+ $disc = $disctag;
+ }
+ $self->disc ( $disc );
+ }
+
return 1;
}
--- a/lib/Audio/File/Ogg/Tag.pm
+++ b/lib/Audio/File/Ogg/Tag.pm
@@ -18,6 +18,7 @@
$self->genre( $self->{ogg}->comment('genre') );
$self->year( $self->{ogg}->comment('date') );
$self->track( $self->{ogg}->comment('tracknumber') );
+ $self->disc( $self->{ogg}->comment('discnumber') );
$self->total( $self->{ogg}->comment('tracktotal') );
return 1;
--- a/lib/Audio/File/Tag.pm
+++ b/lib/Audio/File/Tag.pm
@@ -50,8 +50,8 @@
Using title() you can get or set the tags title field. If called without any
argument it'll return the current content of the title field. If you call
title() with an scalar argument it will set the title field to what the argument
-contains. The methods artist(), album(), comment(), genre(), year(), track() and total()
-are called in the same way.
+contains. The methods artist(), album(), comment(), genre(), year(), track(), disc()
+and total() are called in the same way.
=cut
@@ -163,6 +163,22 @@
}
+=head2 disc
+
+Set/get the disc field in the files tag.
+
+=cut
+
+sub disc {
+ my $self = shift;
+ if ( @_ ) {
+ $self->{disc} = shift;
+ return 1;
+ }
+
+ return $self->{disc};
+}
+
=head2 total
Set/get the total number of tracks.
@@ -204,6 +220,7 @@
genre => $self->genre(),
year => $self->year(),
track => $self->track(),
+ disc => $self->disc(),
total => $self->total()
};
}
@@ -223,6 +240,7 @@
$self->genre() &&
$self->year() &&
$self->track() &&
+ $self->disc() &&
$self->total());
}
|