sub flac2mp3 {
my %a = @_;
+ my $quoted_flac = quote($a{flac});
- my @quoted_pic_options = ();
- # (fd, picfn) = tempfile.mkstemp()
- # os.close(fd)
- # p = Popen(['metaflac', '--export-picture-to', picfn, unquoted_fn],
- # stderr=PIPE)
- # status = p.wait()
- # stderr = ''.join(p.stderr)
- # # Hacky check for flac with no album art
- # if 'no PICTURE block' in stderr:
- # # That's fine, just no picture.
- # pass
- # else:
- # if status != 0:
- # sys.stderr.write('metaflac exited %d: %s\n' % (status, stderr))
- # return
- # pic_options = "--ti '%s'" % picfn
+ say('if metaflac --export-picture-to=flac2mp3.cover.$$ ', $quoted_flac, '; then');
+ say(' pic_options="--ti flac2mp3.cover.$$"');
+ say('fi');
# This is an old TODO; what's wrong with --ty ?
# TODO: Look at TDOR, TDRL, TDRC for date.
say(join(' ',
'flac',
'-cd',
- quote($a{flac}),
+ $quoted_flac,
'|',
'lame',
'--id3v2-only',
quote($a{title}),
'--ty',
quote($a{date}),
- @quoted_pic_options,
+ '$pic_options',
(map { ('--tv', quote("TPE2=$_")) } @{$a{albumartist}}),
(map { ('--tv', quote("TPOS=$_")) } @{$a{discnumber}}),
'-',
. '.mp3'
)
));
+ say('unset pic_options');
+ say('rm -f flac2mp3.cover.$$');
}
sub read_tags_metaflac {