]> diplodocus.org Git - flac-archive/commitdiff
Restore some VERSION support.
authorEric Gillespie <epg@pretzelnet.org>
Sat, 6 Aug 2022 01:06:05 +0000 (20:06 -0500)
committerEric Gillespie <epg@pretzelnet.org>
Sat, 6 Aug 2022 01:06:05 +0000 (20:06 -0500)
Don't put VERSION or PARTNUMBER into filenames on CD.
Those need to stay short!

fa-mp3cd
flac2mp3
tags.pl

index a15318b..523139a 100755 (executable)
--- a/fa-mp3cd
+++ b/fa-mp3cd
@@ -105,8 +105,6 @@ sub filename {
             (map { two_digits($_) } @{$tags->{DISCNUMBER} // []}),
             (map { two_digits($_) } @{$tags->{TRACKNUMBER} // []}),
             @{$tags->{TITLE}},
             (map { two_digits($_) } @{$tags->{DISCNUMBER} // []}),
             (map { two_digits($_) } @{$tags->{TRACKNUMBER} // []}),
             @{$tags->{TITLE}},
-            @{$tags->{VERSION} // []},
-            @{$tags->{PARTNUMBER} // []},
         )
     ) . '.mp3';
 }
         )
     ) . '.mp3';
 }
index e3e3867..4dbb927 100755 (executable)
--- a/flac2mp3
+++ b/flac2mp3
@@ -52,6 +52,7 @@ package epg::flac::archive::mp3;
 use v5.12;
 use warnings;
 
 use v5.12;
 use warnings;
 
+use File::Temp;
 use FindBin;
 
 use lib $FindBin::Bin;
 use FindBin;
 
 use lib $FindBin::Bin;
@@ -72,6 +73,11 @@ sub flac2mp3 {
     my $flac = shift;
     my $tags = shift;
 
     my $flac = shift;
     my $tags = shift;
 
+    my @version;
+    if (defined($tags->{version})) {
+        @version = ('(' . $tags->{version} . ')');
+    }
+
     # This is an old TODO; what's wrong with --ty ?
     # TODO: Look at TDOR, TDRL, TDRC for date.
     say(
     # This is an old TODO; what's wrong with --ty ?
     # TODO: Look at TDOR, TDRL, TDRC for date.
     say(
@@ -93,7 +99,7 @@ sub flac2mp3 {
             '--tn',
             quote($tags->{tracknumber}),
             '--tt',
             '--tn',
             quote($tags->{tracknumber}),
             '--tt',
-            quote($tags->{title}),
+            quote(join(' ', $tags->{title}, @version)),
             '--ty',
             quote($tags->{date}),
             '$pic_options',
             '--ty',
             quote($tags->{date}),
             '$pic_options',
diff --git a/tags.pl b/tags.pl
index d5cbce0..ceb590f 100644 (file)
--- a/tags.pl
+++ b/tags.pl
@@ -204,6 +204,14 @@ sub disc_tags {
         $date = $tags{DATE}->[0];
     }
 
         $date = $tags{DATE}->[0];
     }
 
+    my $version;
+    if (defined($tags{VERSION})) {
+        if (@{$tags{VERSION}} != 1) {
+            die('one or zero VERSION tags required')
+        }
+        $version = $tags{VERSION}->[0];
+    }
+
     my @discnumber = ();
     if (defined($tags{DISCNUMBER})) {
         if (@{$tags{DISCNUMBER}} != 1) {
     my @discnumber = ();
     if (defined($tags{DISCNUMBER})) {
         if (@{$tags{DISCNUMBER}} != 1) {
@@ -225,14 +233,14 @@ sub disc_tags {
         }
     }
 
         }
     }
 
-    $artist, $album_tag, $date, \@discnumber
+    $artist, $album_tag, $date, \@discnumber, $version
 }
 
 # TODO dedup with flac2mp3
 sub track_tags {
     my $tags = shift;
     # TODO probably ought to return hash too.  then track_tags would augment
 }
 
 # TODO dedup with flac2mp3
 sub track_tags {
     my $tags = shift;
     # TODO probably ought to return hash too.  then track_tags would augment
-    my ($artist, $album, $date, $discnumber) = disc_tags(%$tags);
+    my ($artist, $album, $date, $discnumber, $version) = disc_tags(%$tags);
 
         # TODO resurrect whole-disc FLAC?
         # Stupid hack: only a single-track file should have the
 
         # TODO resurrect whole-disc FLAC?
         # Stupid hack: only a single-track file should have the
@@ -255,6 +263,7 @@ sub track_tags {
      discnumber => $discnumber,
      tracknumber => $tracknumber,
      title => $title,
      discnumber => $discnumber,
      tracknumber => $tracknumber,
      title => $title,
+     version => $version,
     )
 }
 
     )
 }
 
@@ -278,6 +287,7 @@ sub mangle_for_file_name {
     $fn =~ s/-[_-]/_/g;          # more
     $fn =~ s/^[_-]+//;           # discard any _ or - at beginning
     $fn =~ s/[_-]+$//;           # at end too
     $fn =~ s/-[_-]/_/g;          # more
     $fn =~ s/^[_-]+//;           # discard any _ or - at beginning
     $fn =~ s/[_-]+$//;           # at end too
+    $fn =~ s/_[_-]/_/g;          # XXX repeated collapse?!  test and fix...
     $fn
 }
 
     $fn
 }