]> diplodocus.org Git - flac-archive/blobdiff - fa-flacd
Move Tags class into new flac_archive package, fix a bug in it, and
[flac-archive] / fa-flacd
index 59b09c4ca47fba18a26155d06b8485f7e2d4e5bc..7e455bf2ba60fc9565772992ad02807a203b6caf 100755 (executable)
--- a/fa-flacd
+++ b/fa-flacd
@@ -1,6 +1,6 @@
 #! /usr/bin/env python2.4
 
-'''
+"""
 =head1 NAME
 
 B<fa-flacd> - archive CDs to single FLAC files
@@ -74,7 +74,7 @@ it under the same terms as Perl itself.
 
 =cut
 
-''' #' # python-mode is sucks
+"""
 
 import os
 import re
@@ -106,6 +106,8 @@ def run_flac(infile, cue, outfile, tags):
     for i in tags:
         argv.extend(['-T', i])
     argv.append(infile)
+    # flac 1.1.3 PICTURE support
+    argv.extend(['--picture', '3|image/jpeg|||cover.front'])
 
     spew('Running flac\n')
     status = os.spawnvp(os.P_WAIT, argv[0], argv)
@@ -117,8 +119,8 @@ def run_flac(infile, cue, outfile, tags):
     c(os.rename, outfile + '.flac-tmp', outfile + '.flac')
 
 def flac(dir, artist, album, discnum, tracknum, track_tags, disc_artist, tags):
-    '''Encode a single wav file to a single flac file, whether the wav and
-    flac files represent individual tracks or whole discs.'''
+    """Encode a single wav file to a single flac file, whether the wav and
+    flac files represent individual tracks or whole discs."""
 
     (artist, album) = [x.replace('/', '_') for x in (artist, album)]
 
@@ -142,7 +144,7 @@ def flac(dir, artist, album, discnum, tracknum, track_tags, disc_artist, tags):
     if tracknum == None:
         outfile = album
         if discnum != None:
-            outfile = ''.join([outfile, ' (disc ', discnum, ')'])
+            outfile = ''.join([discnum, ' ', outfile])
         run_flac('wav', 'cue', '/'.join(['..', artist, outfile]), tags)
         files = ['%s/%s.flac' % (artist, outfile)]
 
@@ -190,8 +192,10 @@ def flac(dir, artist, album, discnum, tracknum, track_tags, disc_artist, tags):
     # Clean up if we're the last job for dir; for multi-file dirs,
     # it's possible for more than one job to run cleanup at once, so
     # don't fail if things are already clean.
-    if os.listdir(dir) == ['using-tags']:
+    ld = os.listdir(dir)
+    if ld == ['using-tags'] or sorted(ld) == ['cover.front', 'using-tags']:
         try:
+            os.unlink(dir + '/cover.front')
             os.unlink(dir + '/using-tags')
             os.rmdir(dir)
         except EnvironmentError:
@@ -203,8 +207,8 @@ def flac(dir, artist, album, discnum, tracknum, track_tags, disc_artist, tags):
 # The master process
 
 def get_tags(fn):
-    '''Return the ARTIST, ALBUM, and DATE followed by a list of all the
-    lines in the file FN.'''
+    """Return the ARTIST, ALBUM, and DATE followed by a list of all the
+    lines in the file FN."""
 
     artist = album = discnum = None
     tags = []