From: epg <> Date: Wed, 27 Apr 2005 06:10:09 +0000 (+0000) Subject: Add DISCNUMBER support. X-Git-Url: https://diplodocus.org/git/flac-archive/commitdiff_plain/c96d51d20abdeefaf4e27377c6bfb69e20f5ea0e?ds=inline;hp=52a5128059b21a2584d18e0ec5f1947f63e414ba Add DISCNUMBER support. --- diff --git a/CHANGES b/CHANGES index 39d09c0..5ace0bd 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,10 @@ svn://diplodocus.org/projects/release/flac-archive-3 won't blow up when some input tags are missing, and takes multiple operands. + * Add DISCNUMBER tag support to fa-flacd and flac2mp3. This is + better than putting "(disc 1)" at the end of ALBUM, though that's + what ends up happening for mp3s due to lame. + Version 2 2004-12-05 svn://diplodocus.org/projects/release/flac-archive-2 diff --git a/fa-flacd b/fa-flacd index d378a1b..3c36372 100755 --- a/fa-flacd +++ b/fa-flacd @@ -38,6 +38,7 @@ sub get_tags { my $value; my $artist; my $album; + my $discnum; my @tags; verbose("Opening tags file $fn\n"); @@ -54,11 +55,14 @@ sub get_tags { } elsif (/^ALBUM=/i) { $album = $value; verbose("ALBUM $album from $fn\n"); # cperl-mode sucks " + } elsif (/^DISCNUMBER=/i) { + $discnum = int($value); + verbose("DISCNUMBER $discnum from $fn\n"); } } close(TAGS) or die("close($fn): $!"); - return ($artist, $album, @tags); + return ($artist, $album, $discnum, @tags); } # Process the fa-rip output in the directory DIR. @@ -66,6 +70,7 @@ sub flac { my $dir = shift; my $artist; my $album; + my $discnum; my @tags; my $outfile; my $status; @@ -74,7 +79,7 @@ sub flac { rename("$dir/tags", "$dir/using-tags") or die("rename($dir/tags, $dir/using-tags): $!"); - ($artist, $album, @tags) = get_tags("$dir/using-tags"); + ($artist, $album, $discnum, @tags) = get_tags("$dir/using-tags"); verbose("mkdir($artist)\n"); -d $artist or mkdir($artist) or die("mkdir($artist): $!"); @@ -83,6 +88,7 @@ sub flac { chdir($dir) or die("chdir($dir): $!"); $outfile = "$album"; + defined($discnum) and $outfile .= " (disc $discnum)"; $outfile =~ s/\//_/g; verbose("Running flac\n"); diff --git a/flac2mp3 b/flac2mp3 index c0cce30..ab83c9f 100755 --- a/flac2mp3 +++ b/flac2mp3 @@ -104,6 +104,7 @@ sub get_tags { my $artist; my $album; my $date; + my $discnum; my $track; open(TAGS, '-|', 'metaflac', '--export-vc-to=-', $fn) @@ -119,6 +120,8 @@ sub get_tags { $album = $value; } elsif (/^DATE=/i) { $date = $value; + } elsif (/^DISCNUMBER=/i) { + $discnum = int($value); } elsif (/^ARTIST\[/i) { push(@$artists, $value); } elsif (/^TRACKNUMBER=/i) { @@ -132,7 +135,7 @@ sub get_tags { } close(TAGS) or die("close(metaflac --export-vc-to=- $fn): $?"); - return ($artist, $album, $date, $track); + return ($artist, $album, $date, $discnum, $track); } sub arg { @@ -210,8 +213,11 @@ MAIN: { for my $fn (@ARGV) { my @args = get_decode_args($fn); my (@artists, @titles); - my ($artist, $album, $date, $track) = get_tags($fn, \@artists, - \@titles); + my ($artist, $album, $date, $discnum, $track) = get_tags($fn, \@artists, + \@titles); + + # lame doesn't seem to support disc number. + defined($discnum) and $album .= " (disc $discnum)"; # Stupid hack: only a single-track file should have the # TRACKNUMBER tag, so use it if set for the first pass through