X-Git-Url: https://diplodocus.org/git/flac-archive/blobdiff_plain/6c58deb659519e8e298a4e65e340a50ba37d6175..refs/heads/master:/flacsplit?ds=inline diff --git a/flacsplit b/flacsplit index 26d3bec..56abfdf 100755 --- 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 () { /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",