command = 'cat '
for media in media_list:
command += '"' + media + '" '
- print command
return SubProcessPipe(command, stdin)
def flac_player(self, media_list, stdin):
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):
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__':
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'):
import string
from mutagen.easyid3 import EasyID3
from mutagen.mp3 import MP3
+import mutagen
from tools import *
EasyID3.valid_keys["comment"]="COMM::'XXX'"
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: