# in the file FN.
sub get_tags {
my $fn = shift;
+ my $artists = shift;
+ my $titles = shift;
my $tag;
my $value;
my $artist;
my $album;
my $date;
- my @titles;
open(TAGS, '-|', 'metaflac', '--export-vc-to=-', $fn)
or die("open(metaflac --export-vc-to=- $fn): $!");
$album = $value;
} elsif (/^DATE=/) {
$date = $value;
+ } elsif (/^ARTIST\[/) {
+ push(@$artists, $value);
# Intentionally don't match the = on this one, to support the
# TITLE[1] .. TITLE[n] tag style.
} elsif (/^TITLE/) {
- push(@titles, $value);
+ push(@$titles, $value);
}
}
close(TAGS) or die("close(metaflac --export-vc-to=- $fn): $?");
- return ($artist, $album, $date, @titles);
+ return ($artist, $album, $date);
}
sub flac2mp3 {
my $fn = shift or pod2usage();
my @args = get_decode_args($fn);
- my ($artist, $album, $date, @titles) = get_tags($fn);
+ my (@artists, @titles);
+ my ($artist, $album, $date) = get_tags($fn, \@artists, \@titles);
for my $i (0..$#titles) {
- flac2mp3($fn, $titles[$i], $artist, $album, $date, $i + 1,
- @{$args[$i]});
+ flac2mp3($fn, $titles[$i], ($artists[$i] or $artist), $album, $date,
+ $i + 1, @{$args[$i]});
}
}