]> diplodocus.org Git - flac-archive/blobdiff - flac2mp3
Hm, why just copy front cover PICTUREs from flac to mp3? The flac
[flac-archive] / flac2mp3
index b4ce99e..982a012 100755 (executable)
--- a/flac2mp3
+++ b/flac2mp3
@@ -61,7 +61,7 @@ from org.diplodocus.util import run_or_die
 ################################################################################
 # The child processes
 
-def flac2mp3(fn, title, artist, album, date, track, skip_until, pic=None):
+def flac2mp3(fn, title, artist, album, date, track, skip_until, pics=None):
     (title, artist, album, date) = [(x == None and 'unknown') or x
                                     for x in (title, artist, album, date)]
     try:
@@ -100,8 +100,8 @@ def flac2mp3(fn, title, artist, album, date, track, skip_until, pic=None):
                   lame_options, title, artist, album, date, track,
                   quoted_outfile))
 
-    if pic != None:
-        taglib.add_apic_frame_to_mp3(outfile, pic[0], pic[1], pic[2])
+    if pics != None:
+        taglib.add_apic_frame_to_mp3(outfile, pics)
 
     return 0
 
@@ -201,17 +201,14 @@ def get_tags(fn):
 
     return tags
 
-def find_pic(fn, tags):
-    pic = tags.get('__flac2mp3_PICTURE')
+def find_pics(fn, tags):
+    pics = tags.get('__flac2mp3_PICTURE')
 
-    if not isinstance(pic, tuple):
-        for i in flac.get_pictures(fn):
-            if i[1] == flac.PICTURE_TYPE_FRONT_COVER:
-                pic = i[:3]
-                break
-        tags.set('__flac2mp3_PICTURE', pic)
+    if not isinstance(pics, list):
+        pics = flac.get_pictures(fn)
+        tags.set('__flac2mp3_PICTURE', pics)
 
-    return pic
+    return pics
 
 def main(argv):
     # Control the exit code for any uncaught exceptions.
@@ -275,7 +272,7 @@ def main(argv):
                                  tags.gets('ARTIST', track),
                                  album,
                                  tags.gets('DATE', track),
-                                 track, args[i], find_pic(fn, tags)])
+                                 track, args[i], find_pics(fn, tags)])
                     track = i + 2
             except Exception, error:
                 sys.stderr.write(getattr(error, 'msg', ''))