]> diplodocus.org Git - flac-archive/commitdiff
Aug 5 21:35 fresh
authorEric Gillespie <epg@timescale.com>
Tue, 11 Oct 2022 00:10:49 +0000 (19:10 -0500)
committerEric Gillespie <epg@timescale.com>
Tue, 11 Oct 2022 00:10:49 +0000 (19:10 -0500)
tags.pl

diff --git a/tags.pl b/tags.pl
index c65a276..395e1c4 100644 (file)
--- a/tags.pl
+++ b/tags.pl
@@ -57,6 +57,16 @@ TODO
 # ARTIST[5]=Reba McEntire
 # ARTIST[5]=Vince Gill
 
+# TODO
+# - sub filename in (fa-encode, fa-mp3cd, and flac2mp3) TESTED
+#   - use PART, PARTNUMBER, VERSION in those filenames
+# - replace tags.pl with fa-tags which the others still import but which is a tool
+# - perltidy
+#   - -bt=2    Strictest brace tightness
+#   - -pt=2    Strictest paren tightness
+#   - -nvc     No vertical code alignment
+#   - -se      errors to stderr...  how is this not the default?
+
 use v5.12;
 use warnings;
 
@@ -97,7 +107,9 @@ sub read_tags {
                 warn("looks like DESCRIPTION had multiple lines; discarding and returning early: $_");
                 last
             }
-            die("no field name in:  $_");
+           # TODO oops i left 'TITLE[]=(pregap)' in every file for R.E.M. - Monster!
+            warn("no field name in:  $_");
+           next
         }
         $name = $1;
         # TODO validate $name
@@ -194,6 +206,14 @@ sub disc_tags {
         $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) {
@@ -215,14 +235,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
-    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
@@ -245,6 +265,7 @@ sub track_tags {
      discnumber => $discnumber,
      tracknumber => $tracknumber,
      title => $title,
+     version => $version,
     )
 }
 
@@ -268,6 +289,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;          # XXX repeated collapse?!  test and fix...
     $fn
 }