]> diplodocus.org Git - flac-archive/commitdiff
Copy ALBUMARTIST from FLAC file to TPE2 in ID3.
authorepg@pretzelnet.org <>
Sun, 1 Jan 2012 18:37:58 +0000 (10:37 -0800)
committerepg@pretzelnet.org <>
Sun, 1 Jan 2012 18:37:58 +0000 (10:37 -0800)
flac2mp3

index f86206274dc127892f0ddc1a8862965797953cea..2233dd9c29e4d670e286acbb00cee9125bb7bee7 100755 (executable)
--- a/flac2mp3
+++ b/flac2mp3
@@ -1,4 +1,4 @@
-#! /usr/bin/env python2.4
+#!/usr/bin/python
 
 """
 =head1 NAME
 
 """
 =head1 NAME
@@ -63,7 +63,8 @@ from flac_archive.tags import Tags
 ################################################################################
 # The child processes
 
 ################################################################################
 # The child processes
 
-def flac2mp3(fn, title, artist, album, date, track, skip_until, pics=None):
+def flac2mp3(fn, title, artist, album_artist, album, date,
+             track, skip_until, pics=None):
     (title, artist, album) = [(x == None and 'unknown') or x
                               for x in (title, artist, album)]
     if date == None:
     (title, artist, album) = [(x == None and 'unknown') or x
                               for x in (title, artist, album)]
     if date == None:
@@ -88,17 +89,21 @@ def flac2mp3(fn, title, artist, album, date, track, skip_until, pics=None):
                                         track, title)).replace('/', '_')
 
     # Escape any single quotes ' so we can quote this.
                                         track, title)).replace('/', '_')
 
     # Escape any single quotes ' so we can quote this.
-    (fn, title, artist,
-     album, date) = [x.replace("'", r"'\''")
-                     for x in (fn, title, artist, album, date)]
+    (fn, title, artist, album_artist,
+     album, date) = [(x or '').replace("'", r"'\''")
+                     for x in [fn, title, artist, album_artist, album, date]]
+
+    album_artist_options = ''
+    if album_artist:
+        album_artist_options = "--tv 'TPE2=%s'" % album_artist
 
     quoted_outfile = ('%s (%s) %02d %s.mp3' % (artist, album,
                                                track, title)).replace('/', '_')
 
 
     quoted_outfile = ('%s (%s) %02d %s.mp3' % (artist, album,
                                                track, title)).replace('/', '_')
 
-    run_or_die(3, "flac %s -cd %s '%s' | lame --add-id3v2 %s --tt '%s' --ta '%s' --tl '%s' --ty '%s' --tn %d - '%s'"
+    run_or_die(3, "flac %s -cd %s '%s' | lame --add-id3v2 %s --tt '%s' --ta '%s' --tl '%s' --ty '%s' --tn %d %s - '%s'"
                % (flac_options, ' '.join(skip_until), fn,
                   lame_options, title, artist, album, date, track,
                % (flac_options, ' '.join(skip_until), fn,
                   lame_options, title, artist, album, date, track,
-                  quoted_outfile))
+                  album_artist_options, quoted_outfile))
 
     if pics != None:
         taglib.add_apic_frame_to_mp3(outfile, pics)
 
     if pics != None:
         taglib.add_apic_frame_to_mp3(outfile, pics)
@@ -225,9 +230,10 @@ def main(argv):
                         title = '%s - %s' % (title, part)
                     artist = tags.get('ARTIST', track)
                     artist.extend(tags.get('FEATURING', track))
                         title = '%s - %s' % (title, part)
                     artist = tags.get('ARTIST', track)
                     artist.extend(tags.get('FEATURING', track))
+                    album_artist = tags.gets('ALBUMARTIST', track)
                     jobs.append([fn, title,
                                  ', '.join(artist),
                     jobs.append([fn, title,
                                  ', '.join(artist),
-                                 album,
+                                 album_artist, album,
                                  tags.gets('DATE', track),
                                  track, args[i], pics])
                     track = i + 2
                                  tags.gets('DATE', track),
                                  track, args[i], pics])
                     track = i + 2