- picfn = None
- if pics:
- (fd, picfn) = tempfile.mkstemp()
- f = os.fdopen(fd, 'wb')
- f.write(pics[0][7])
- f.close()
+ 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