"""Defines methods to export to FLAC"""
implements(IExporter)
-
+
def __init__(self):
self.item_id = ''
self.source = ''
def get_format(self):
return 'FLAC'
-
+
def get_file_extension(self):
return 'flac'
def set_cache_dir(self,path):
"""Set the directory where cached files should be stored. Does nothing
- if the exporter doesn't support caching.
-
+ if the exporter doesn't support caching.
+
The driver shouldn't assume that this method will always get called. A
temporary directory should be used if that's not the case.
"""
self.args = self.get_args(options)
self.ext = self.get_file_extension()
self.args = ' '.join(self.args)
- self.command = 'sox "%s" -s -q -b 16 -r 44100 -t wav -c2 - | flac -c %s - ' % (self.source, self.args)
+ self.command = 'sox "%s" -s -q -b 16 -t wav -c2 - | flac -c %s - ' % (self.source, self.args)
# Pre-proccessing
self.dest = self.pre_process(self.item_id,
self.write_tags(self.dest)
file = open(self.dest,'r')
-
+
while True:
chunk = file.read(self.buffer_size)
if len(chunk) == 0:
"""Defines methods to export to MP3"""
implements(IExporter)
-
+
def __init__(self):
self.item_id = ''
self.metadata = {}
}
def get_format(self):
return 'MP3'
-
+
def get_file_extension(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():
def get_args(self, options=None):
"""Get process options and return arguments for the encoder"""
args = []
- if not options is None:
+ if not options is None:
self.options = options
if not ( 'verbose' in self.options and self.options['verbose'] != '0' ):
args.append('-S')
self.args = self.get_args(options)
self.ext = self.get_file_extension()
self.args = ' '.join(self.args)
- self.command = 'sox "%s" -q -b 16 -r 44100 -t wav - | lame %s -' % (self.source, self.args)
+ self.command = 'sox "%s" -q -b 16 -t wav - | lame %s -' % (self.source, self.args)
#self.command = 'lame %s "%s" -' % (self.args, self.source)
# Pre-proccessing
stream = self.core_process(self.command, self.buffer_size, self.dest)
for chunk in stream:
yield chunk
-
+
# Post-proccessing
#self.post_process(self.item_id,
#self.source,
"""Defines methods to export to OGG Vorbis"""
implements(IExporter)
-
+
def __init__(self):
self.item_id = ''
self.metadata = {}
self.dub2args_dict = {'creator': 'artist',
'relation': 'album'
}
-
+
def get_format(self):
return 'OGG'
-
+
def get_file_extension(self):
return 'ogg'
self.args = self.get_args(options)
self.ext = self.get_file_extension()
self.args = ' '.join(self.args)
- self.command = 'sox "%s" -s -q -b 16 -r 44100 -t wav -c2 - | oggenc %s -' % (self.source, self.args)
+ self.command = 'sox "%s" -s -q -b 16 -t wav -c2 - | oggenc %s -' % (self.source, self.args)
# Pre-proccessing
self.dest = self.pre_process(self.item_id,
stream = self.core_process(self.command, self.buffer_size, self.dest)
for chunk in stream:
yield chunk
-
+
# Post-proccessing
#self.post_process(self.item_id,
#self.source,