]> diplodocus.org Git - flac-archive/blobdiff - flac2mp3
UNTESTED: Refactor the job parallelization stuff into a generic Jobs package.
[flac-archive] / flac2mp3
index c0cce30a5ab06a7b8de6d5e80df507c89435ca4e..21cf9c55e2af993ec363bed90f286a5b2e267532 100755 (executable)
--- 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,12 @@ sub get_tags {
     }
     close(TAGS) or die("close(metaflac --export-vc-to=- $fn): $?");
 
-    return ($artist, $album, $date, $track);
+    # If no TITLEs, stick a dummy in here.
+    if (@$titles == 0) {
+        push(@$titles, undef);
+    }
+
+    return ($artist, $album, $date, $discnum, $track);
 }
 
 sub arg {
@@ -148,10 +156,10 @@ sub arg {
 
 sub flac2mp3 {
     my $fn = shift;
-    my $title = shift;
-    my $artist = shift;
-    my $album = shift;
-    my $date = shift;
+    my $title = (shift or 'unknown');
+    my $artist = (shift or 'unknown');
+    my $album = (shift or 'unknown');
+    my $date = (shift or 'unknown');
     my $track = int(shift);
     my $skip_arg = shift;
     my $until_arg = shift;
@@ -210,8 +218,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