]> diplodocus.org Git - flac-archive/blobdiff - fa-flacd
Commit a bunch of state sitting around in the old bzr checkout!
[flac-archive] / fa-flacd
index e291b75a8b66439abda1fad0cc929048e6f5b021..5716223f8c5b360c4e5fa58e1760fca23fd69fae 100755 (executable)
--- a/fa-flacd
+++ b/fa-flacd
@@ -1,4 +1,4 @@
-#! /usr/bin/env python2.4
+#! /usr/bin/python2
 
 """
 =head1 NAME
@@ -109,7 +109,8 @@ def run_flac(infile, cue, outfile, tags):
         argv.extend(['-T', i])
     argv.append(infile)
     # flac 1.1.3 PICTURE support
-    argv.extend(['--picture', '3|image/jpeg|||cover.front'])
+    if os.path.exists('cover.front'):
+        argv.extend(['--picture', '3|image/jpeg|||cover.front'])
 
     spew('Running flac\n')
     status = os.spawnvp(os.P_WAIT, argv[0], argv)
@@ -125,7 +126,11 @@ def flac(dir, tracknum, tags):
     flac files represent individual tracks or whole discs."""
 
     separator = ' '
-    artist = (tags.gets('ARTIST', separator=', ') or '').replace('/', '_')
+    if len(tags.get('ALBUMARTIST')) > 0:
+        artist_tag = tags.gets('ALBUMARTIST', separator=', ')
+    else:
+        artist_tag = tags.gets('ARTIST', separator=', ')
+    artist = (artist_tag or '').replace('/', '_')
     album = (tags.gets('ALBUM', separator=separator) or '').replace('/', '_')
     discnum = tags.gets('DISCNUMBER')
 
@@ -153,7 +158,12 @@ def flac(dir, tracknum, tags):
         run_flac('wav', 'cue', '/'.join(['..', artist, outfile]), tags.all())
         files = ['%s/%s.flac' % (artist, outfile)]
 
-        c(os.unlink, 'cue')
+        try:
+            c(os.unlink, 'cue')
+        except EnvironmentError, error:
+            if error.errno != ENOENT:
+                raise error
+
         outlog = '/'.join(['..', artist, outfile + '.log'])
         c(os.rename, 'log', outlog)
     else:
@@ -189,7 +199,10 @@ def flac(dir, tracknum, tags):
     ld = os.listdir(dir)
     if ld == ['using-tags'] or sorted(ld) == ['cover.front', 'using-tags']:
         try:
-            os.unlink(dir + '/cover.front')
+            try:
+                os.unlink(dir + '/cover.front')
+            except OSError:
+                pass
             os.unlink(dir + '/using-tags')
             os.rmdir(dir)
         except EnvironmentError: