- my $fn = shift or pod2usage();
- my @args = get_decode_args($fn);
- my ($artist, $album, $date, @titles) = get_tags($fn);
-
- for my $i (0..$#titles) {
- flac2mp3($fn, $titles[$i], $artist, $album, $date, $i + 1,
- @{$args[$i]});
+ my $help;
+ GetOptions(
+ 'lame-options=s', \$lame_options,
+ 'quiet|q' => \$quiet,
+ 'verbose|v' => \$verbose,
+ 'help|h|?' => \$help,
+ ) or pod2usage();
+ $help and pod2usage(-exitstatus=>0, -verbose=>1);
+
+ @ARGV or pod2usage();
+ for my $fn (@ARGV) {
+ my @args = get_decode_args($fn);
+ my (@artists, @titles);
+ my ($artist, $album, $date, $discnum, $track) = get_tags($fn, \@artists,
+ \@titles);
+
+ # lame doesn't seem to support disc number.
+ defined($discnum) and $album .= " (disc $discnum)";
+
+ # Stupid hack: only a single-track file should have the
+ # TRACKNUMBER tag, so use it if set for the first pass through
+ # the loop. At the end of the loop, we'll set $track for the
+ # next run, so this continues to work for multi-track files.
+ $track ||= 1;
+
+ for my $i (0..$#titles) {
+ flac2mp3($fn, $titles[$i], ($artists[$i] or $artist), $album, $date,
+ $track, @{$args[$i]});
+ $track = $i + 2;
+ }