]> diplodocus.org Git - flac-archive/blobdiff - flacsplit
fix tests after shortening CD filenames
[flac-archive] / flacsplit
index 26d3bec0304ddf58f3f9defc4dfa22c6a7a89865..56abfdf9e5ed7be5c60518e7cdc44d2d18d3eb59 100755 (executable)
--- a/flacsplit
+++ b/flacsplit
@@ -42,7 +42,8 @@ sub get_decode_args {
     my $fn = shift;
     my @l;
 
-    open(F, '-|', 'metaflac', '--export-cuesheet-to=-', $fn);
+    open(F, '-|', 'metaflac', '--no-utf8-convert', '--export-cuesheet-to=-',
+         $fn);
     while (<F>) {
         /INDEX 01 (\d\d):(\d\d):(\d\d)$/ or next;
         push(@l, [$1, $2, $3]);
@@ -128,14 +129,14 @@ sub flacsplit {
     my $discnum;
     my @tags;
     my $outdir;
-    my $outfile;
 
-    open(my $fp, '-|', 'metaflac', '--export-tags-to=-', $fn)
-      or die("open(metaflac --export-tags-to=- $fn): $!");
+    open(my $fp, '-|', 'metaflac', '--no-utf8-convert', '--export-tags-to=-',
+         $fn)
+      or die("open(metaflac --no-utf8-convert --export-tags-to=- $fn): $!");
     ($artist, $album, $discnum, @tags) = get_tags($fp, $fn);
-    close($fp) or die("close(metaflac --export-tags-to=- $fn): $?");
+    close($fp)
+        or die("close(metaflac --no-utf8-convert --export-tags-to=- $fn): $?");
     for ($artist, $album) {
-        s/'/'\\''/g;
         s|/|_|g;
     }
 
@@ -167,16 +168,15 @@ sub flacsplit {
 
     for my $tracknum (sort(map(int, keys(%tracks_to_tags)))) {
         my $title = join(' ', map(split, @{$tracks_to_tags{$tracknum}->{'TITLE'}}));
-        $title =~ s/'/'\\''/g;
-        $title =~ s|/|_|g;
-        $outfile = join('/',
-                        $outdir,
-                        join(' ',
-                             (defined($discnum)
-                              ? sprintf('%02d', $discnum)
-                              : ()),
-                             sprintf('%02d', $tracknum),
-                             $title));
+        my $outfile = join(' ',
+                           (defined($discnum)
+                            ? sprintf('%02d', $discnum)
+                            : ()),
+                           sprintf('%02d', $tracknum),
+                           $title);
+        $outfile =~ s|/|_|g;
+        $outfile = "$outdir/$outfile";
+        $outfile =~ s/'/'\\''/g;
 
         # If we have ARTIST[n] tags for this track, set @track_artist
         # to the empty list; they will go in along with the other [n]
@@ -195,7 +195,7 @@ sub flacsplit {
         run_or_die(join(' ',
                         "flac $flac_options -cd $skip_arg $until_arg '$fn'",
                         " | flac -o '$outfile.flac' -V --no-padding --best",
-                        map({ s/'/'\\''/g; ('-T', "'$_'") }
+                        map({ my $tag = "$_"; $tag =~ s/'/'\\''/g; ('-T', "'$tag'") }
                             @track_artist,
                             @tags,
                             "TRACKNUMBER=$tracknum",