]> git.parisson.com Git - telemaster.git/commitdiff
fix metadata wrinting, recursive mix encoding OK !
authoryomguy <yomguy@353fd7da-fb10-4236-9bec-1a49139083f2>
Fri, 1 May 2009 16:17:17 +0000 (16:17 +0000)
committeryomguy <yomguy@353fd7da-fb10-4236-9bec-1a49139083f2>
Fri, 1 May 2009 16:17:17 +0000 (16:17 +0000)
git-svn-id: http://svn.parisson.org/svn/telemaster/trunk@8 353fd7da-fb10-4236-9bec-1a49139083f2

flac2mp3mix.py
tools/flac.py
tools/mp3.py

index ad5a95f4f9b024e023fd3d819152a30c128f7eb2..11b32efe4e9cf451e6c0eba7f815b28b45123eb0 100644 (file)
@@ -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__':
index 8d2ec89ef162cbeb70f6a8171c4ba9f155de8154..26345ee7f46b0f07b877e22d6db0c32089874a8e 100644 (file)
@@ -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'):
index ca47c79d09abfb2b72b2ced4ca5457f1d422f90f..08628775f5afa5cc1445d7b9a6cb69e49af0aa1e 100644 (file)
@@ -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: