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());
 }
 
