From: epg@pretzelnet.org <> Date: Sun, 1 Jan 2012 18:37:58 +0000 (-0800) Subject: Copy ALBUMARTIST from FLAC file to TPE2 in ID3. X-Git-Url: https://diplodocus.org/git/flac-archive/commitdiff_plain/c0973ded46cf1aabd5225501ea02a4f5f8e84a5c?hp=b989bba3a1183f9dc004ebf7aeb333469aef392f Copy ALBUMARTIST from FLAC file to TPE2 in ID3. --- diff --git a/flac2mp3 b/flac2mp3 index f862062..2233dd9 100755 --- a/flac2mp3 +++ b/flac2mp3 @@ -1,4 +1,4 @@ -#! /usr/bin/env python2.4 +#!/usr/bin/python """ =head1 NAME @@ -63,7 +63,8 @@ from flac_archive.tags import Tags ################################################################################ # 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: @@ -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. - (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('/', '_') - 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, - quoted_outfile)) + album_artist_options, quoted_outfile)) 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)) + album_artist = tags.gets('ALBUMARTIST', track) jobs.append([fn, title, ', '.join(artist), - album, + album_artist, album, tags.gets('DATE', track), track, args[i], pics]) track = i + 2