self.buffer_size = 0xFFFF
self.dub2id3_dict = {'title': 'TIT2', #title2
'creator': 'TCOM', #composer
- 'creator': 'TPE1', #lead
- 'identifier': 'UFID', #Unique ID...
- 'identifier': 'TALB', #album
- #'date': 'TYER', #year
- 'type': 'TCON', #genre
- 'publisher': 'TPUB', #comment
- }
-
+ 'creator': 'TPE1', #lead
+ 'identifier': 'UFID', #Unique ID...
+ 'identifier': 'TALB', #album
+ 'type': 'TCON', #genre
+ 'publisher': 'TPUB', #comment
+ #'date': 'TYER', #year
+ }
+ self.dub2args_dict = {'title': 'tt', #title2
+ 'creator': 'ta', #composer
+ 'identifier': 'tl', #album
+ #'type': 'tg', #genre
+ 'publisher': 'tc', #comment
+ 'date': 'ty', #year
+ }
def get_format(self):
return 'MP3'
def write_tags(self):
"""Write all ID3v2.4 tags by mapping dub2id3_dict dictionnary with the
respect of mutagen classes and methods"""
- from mutagen import id3
-
+ from mutagen import id3
id3 = id3.ID3(self.dest)
for tag in self.metadata.keys():
if tag in self.dub2id3_dict.keys():
id3.add(frame)
id3.save()
- def get_args(self,options=None):
+ def get_args(self, metadata, options=None):
"""Get process options and return arguments for the encoder"""
args = ''
if not options is None:
else:
args = args + ' -S -c -o '
+ for tag in self.metadata.keys():
+ if tag in self.dub2args_dict.keys():
+ arg = self.dub2args_dict[tag]
+ value = self.metadata[tag]
+ args = args + ' --' + arg + ' "' +value +'" '
+
return args
def process(self, item_id, source, metadata, options=None):
self.source = source
self.metadata = metadata
#self.options = {}
- self.args = self.get_args(options)
+ self.args = self.get_args(self.metadata,options)
self.ext = self.get_file_extension()
self.command = 'sox "'+self.source+'" -q -w -r 44100 -t wav -c2 - '+ \
- '| lame '+self.args+' --tc "default" - -'
+ '| lame '+self.args+' - -'
# Pre-proccessing
try:
yield 'ExporterError: core_process'
# Post-proccessing
- try:
- self.write_tags()
+ try:
self.post_process(self.item_id,
self.source,
self.metadata,
from telemeta.export.api import IExporter
class WavExporter(ExporterCore):
- """Defines methods to export to OGG Vorbis"""
+ """Defines methods to export to WAV"""
implements(IExporter)
if not options is None:
self.options = options
try:
- # Pre-proccessing (core)
+ # Pre-proccessing
self.ext = self.get_file_extension()
self.dest = self.pre_process(self.item_id,
self.source,
yield chunk
file_out.write(chunk)
- # Processing
+ # Core Processing
while chunk:
chunk = file_in.read(self.buffer_size)
yield chunk
file_in.close()
file_out.close()
- self.write_tags()
# Create the md5 key
#if 'md5' in self.metadata and self.metadata['md5']:
#if 'par2' in self.metadata and self.metadata['par2']:
self.create_par_key()
+ # Pre-proccessing
self.post_process(self.item_id,
self.source,
self.metadata,
<p><b>Listen to this collection</b>
(<a href="{% url telemeta-collection-m3u object.id|urlencode %}">M3U</a>,
<a href="{% url telemeta-collection-xspf object.id|urlencode %}">XSPF</a>)</p>
- {% if 0 %} {# Use 1/0 for alternate player #}
+ {% if 1 %} {# Use 1/0 for alternate player #}
<!-- This is the XSPF Web Music Player, under the BSD license,
from: http://musicplayer.sourceforge.net/-->
<object type="application/x-shockwave-flash" width="300" height="200"