From 1c0e9461c467c041d9442b12af9386510ba40451 Mon Sep 17 00:00:00 2001 From: "epg@pretzelnet.org" <> Date: Tue, 24 Jul 2012 14:52:43 -0700 Subject: [PATCH] lame supports adding album art directly, it's just not very well documented (still not in the man page in latest release), so switch to that instead of my crappy taglib module --- flac2mp3 | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) mode change 100644 => 100755 flac2mp3 diff --git a/flac2mp3 b/flac2mp3 old mode 100644 new mode 100755 index 77c586e..55f858d --- a/flac2mp3 +++ b/flac2mp3 @@ -50,14 +50,14 @@ Written by Eric Gillespie . """ -import re, sys, traceback +import os, re, sys, tempfile, traceback from optparse import OptionParser from subprocess import Popen, PIPE import org.diplodocus.jobs from org.diplodocus.util import run_or_die -from flac_archive import flac, taglib +from flac_archive import flac from flac_archive.tags import Tags ################################################################################ @@ -99,13 +99,24 @@ def flac2mp3(fn, title, artist, album_artist, album, date, quoted_outfile = ('%s (%s) %02d %s.mp3' % (artist, album, track, title)).replace('/', '_') - run_or_die(3, "flac %s -cd %s '%s' | lame --id3v2-only %s --tt '%s' --ta '%s' --tl '%s' --ty '%s' --tn %d %s - '%s'" - % (flac_options, ' '.join(skip_until), fn, - lame_options, title, artist, album, date, track, - album_artist_options, quoted_outfile)) - if pics != None: - taglib.add_apic_frame_to_mp3(outfile, pics) + picfn = None + if pics: + (fd, picfn) = tempfile.mkstemp() + f = os.fdopen(fd, 'wb') + f.write(pics[0][7]) + f.close() + try: + run_or_die(3, "flac %s -cd %s '%s' | lame --id3v2-only %s --tt '%s' --ta '%s' --tl '%s' --ty '%s' --tn %d --ti '%s' %s - '%s'" + % (flac_options, ' '.join(skip_until), fn, + lame_options, title, artist, album, date, track, + picfn, album_artist_options, quoted_outfile)) + finally: + if picfn: + try: + os.unlink(picfn) + except: + pass return 0 -- 2.56.0