#! /usr/bin/env python2.4
-'''
+"""
=head1 NAME
B<fa-flacd> - archive CDs to single FLAC files
=cut
-''' #' # python-mode is sucks
+"""
import os
import re
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)
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)]
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)]
# 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:
# 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 = []