From: epg <> Date: Mon, 17 Apr 2006 23:59:34 +0000 (+0000) Subject: Support multi- and single- file modes. X-Git-Url: https://diplodocus.org/git/flac-archive/commitdiff_plain/c3c2f3fcc2721a9c6cc9b7fc4127bdff56d233d4?hp=af28e6fa66b0592c23744868ee174dba8b1c8fd5 Support multi- and single- file modes. --- diff --git a/fa-flacd b/fa-flacd index b9f883c..f2e20b7 100755 --- a/fa-flacd +++ b/fa-flacd @@ -117,7 +117,11 @@ sub flac { my $album; my $discnum; my @tags; + my $single_file = -e "$dir/wav"; + my $outdir; my $outfile; + my $outlog; + my @files; verbose("Renaming $dir/tags\n"); rename("$dir/tags", "$dir/using-tags") @@ -131,62 +135,72 @@ sub flac { verbose("mkdir($artist)\n"); -d $artist or mkdir($artist) or die("mkdir($artist): $!"); - my $outdir = "$artist/$album"; - verbose("mkdir($outdir)\n"); - -d "$outdir" or mkdir("$outdir") or die("mkdir($outdir): $!"); + if (not $single_file) { + $outdir = "$artist/$album"; + verbose("mkdir($outdir)\n"); + -d "$outdir" or mkdir("$outdir") or die("mkdir($outdir): $!"); + } verbose("chdir($dir)\n"); chdir($dir) or die("chdir($dir): $!"); - my @artist; - my %things; - my (@bork, @titles); - for my $tag (@tags) { - if ($tag =~ /^([^[]+)\[(\d+)]=(.*)/) { - push(@{$things{$2}->{$1}}, $3); - } elsif ($tag =~ /^ARTIST=/) { - push(@artist, $tag); - } else { - push(@bork, $tag); + if ($single_file) { + $outfile = $album; + defined($discnum) and $outfile .= " (disc $discnum)"; + run_flac('wav', 'cue', "../$artist/$outfile", @tags); + $outlog = "../$artist/$outfile.log"; + @files = ("$artist/$outfile.flac"); + } else { + my %things; + my @artist; + my @bork; + for my $tag (@tags) { + if ($tag =~ /^([^[]+)\[(\d+)]=(.*)/) { + push(@{$things{$2}->{$1}}, $3); + } elsif ($tag =~ /^ARTIST=/) { + push(@artist, $tag); + } else { + push(@bork, $tag); + } } - } - @tags = @bork; + @tags = @bork; + + for my $tracknum (sort(map(int, keys(%things)))) { + my $title = join(' ', map(split, @{$things{$tracknum}->{'TITLE'}})); + $title =~ s|/|_|g; + $outfile = join(' ', + (defined($discnum) + ? sprintf('%02d', $discnum) + : ()), + sprintf('%02d', $tracknum), + $title); + push(@files, "$outdir/$outfile.flac"); + $outfile = "../$outdir/$outfile"; + + my @lartist; + if (exists($things{$tracknum}->{'ARTIST'})) { + @lartist = (); + } else { + @lartist = @artist; + } - my @files; - for my $tracknum (sort(map(int, keys(%things)))) { - my $title = join(' ', map(split, @{$things{$tracknum}->{'TITLE'}})); - $title =~ s|/|_|g; - $outfile = join(' ', - (defined($discnum) - ? sprintf('%02d', $discnum) - : ()), - sprintf('%02d', $tracknum), - $title); - push(@files, "$outdir/$outfile.flac"); - $outfile = "../$outdir/$outfile"; - - my @lartist; - if (exists($things{$tracknum}->{'ARTIST'})) { - @lartist = (); - } else { - @lartist = @artist; + run_flac(sprintf('track%02d.cdda.wav', $tracknum), undef, $outfile, + @lartist, + grep({ $_ !~ /^ARTIST=/ } @tags), + bork_tags($things{$tracknum})); + $outlog = "../$outdir/log"; } - - run_flac(sprintf('track%02d.cdda.wav', $tracknum), undef, $outfile, - @lartist, - grep({ $_ !~ /^ARTIST=/ } @tags), - bork_tags($things{$tracknum})); } verbose("Cleaning up $dir\n"); unlink('using-tags') or die("unlink(using-tags): $!"); unlink('cue') or die("unlink(cue): $!"); - rename('log', "../$outdir/log") - or die("rename(log, ../$outdir/log): $!"); + rename('log', $outlog) + or die("rename(log, $outlog): $!"); chdir('..') or die("chdir(..): $!"); if (-x "$dir/post-processor") { - verbose("Running './$dir/post-processor'\n"); + verbose(join(' ', 'Running', @files), "\n"); system("./$dir/post-processor", @files); unlink("$dir/post-processor") or die("unlink($dir/post-processor): $!"); }