From c8f4b8bc61d9e9c06167a0938933b33719d0c662 Mon Sep 17 00:00:00 2001 From: yomguy Date: Fri, 1 May 2009 16:17:17 +0000 Subject: [PATCH] fix metadata wrinting, recursive mix encoding OK ! git-svn-id: http://svn.parisson.org/svn/telemaster/trunk@8 353fd7da-fb10-4236-9bec-1a49139083f2 --- flac2mp3mix.py | 21 +++++++++------------ tools/flac.py | 4 ++-- tools/mp3.py | 11 ++++++----- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/flac2mp3mix.py b/flac2mp3mix.py index ad5a95f..11b32ef 100644 --- a/flac2mp3mix.py +++ b/flac2mp3mix.py @@ -51,7 +51,6 @@ class Flac2Mp3Mix: command = 'cat ' for media in media_list: command += '"' + media + '" ' - print command return SubProcessPipe(command, stdin) def flac_player(self, media_list, stdin): @@ -63,7 +62,7 @@ class Flac2Mp3Mix: def mp3_encode(self, stdin, file): - command = 'lame -b 256 - "' + file + '"' + command = 'lame -b 256 --tt "xxx" - "' + file + '"' return SubProcessPipe(command, stdin) def get_media_lists(self): @@ -84,27 +83,25 @@ class Flac2Mp3Mix: if media_list: media_list.sort() root_dir = os.sep.join(media_list[0].split(os.sep)[:-1]) - print root_dir - album_name = root_dir.split(os.sep)[-2] - print album_name - media_0 = media_list[0] + print 'Mixing : ' + print media_list flac = Flac(media_0) metadata = flac.get_tags() - mp3_file = root_dir + os.sep + album_name + '.mp3' + album_name = metadata['album'] + mp3_file = root_dir + os.sep + album_name + '.mp3' + #if not os.path.exists(mp3_file): f = self.flac_player(media_list, None) m = self.mp3_encode(f.stdout, mp3_file) - print 'Mixing : ' - print media_list - print 'Encoding...' + print 'Encoding ' + mp3_file m.proc.wait() print 'Writing metadata...' mp3 = Mp3(mp3_file) mp3.metadata = metadata + mp3.metadata['title'] = album_name + mp3.metadata['comment'] = 'Cellar_playlist' mp3.write_tags() print 'Done !' - break - if __name__ == '__main__': diff --git a/tools/flac.py b/tools/flac.py index 8d2ec89..26345ee 100644 --- a/tools/flac.py +++ b/tools/flac.py @@ -118,8 +118,8 @@ class Flac: metadata['artist'] = audio['artist'][0] if audio.has_key('album'): metadata['album'] = audio['album'][0] - if audio.has_key('year'): - metadata['year'] = audio['year'][0] + if audio.has_key('date'): + metadata['date'] = audio['date'][0] if audio.has_key('comment'): metadata['comment'] = audio['comment'][0] if audio.has_key('genre'): diff --git a/tools/mp3.py b/tools/mp3.py index ca47c79..0862877 100644 --- a/tools/mp3.py +++ b/tools/mp3.py @@ -40,6 +40,7 @@ import os import string from mutagen.easyid3 import EasyID3 from mutagen.mp3 import MP3 +import mutagen from tools import * EasyID3.valid_keys["comment"]="COMM::'XXX'" @@ -105,14 +106,14 @@ class Mp3: raise IOError('ExporterError: decoder is not compatible.') def write_tags(self): - """Write all ID3v2.4 tags by mapping dub2id3_dict dictionnary with the + """Write all ID3v2.4 tags by mapping keys2id3 dictionnary with the respect of mutagen classes and methods""" - id3 = id3.ID3(self.media) + id3 = mutagen.id3.ID3(self.media) for tag in self.metadata.keys(): - if tag in self.dub2id3_dict.keys(): - frame_text = self.dub2id3_dict[tag] + if tag in self.keys2id3.keys(): + frame_text = self.keys2id3[tag] value = self.metadata[tag] - frame = mutagen.id3.Frames[frame_text](3,value) + frame = mutagen.id3.Frames[frame_text](encoding=3,text=value) try: id3.add(frame) except: -- 2.39.5