From: yomguy <> Date: Mon, 28 May 2007 00:12:51 +0000 (+0000) Subject: Added metadata to OGG stream X-Git-Tag: 1.1~894 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=8d24aac9c90a979da94552ed181cd07cfd631ba6;p=telemeta.git Added metadata to OGG stream --- diff --git a/telemeta/export/flac.py b/telemeta/export/flac.py index acffa56d..77f319dc 100644 --- a/telemeta/export/flac.py +++ b/telemeta/export/flac.py @@ -87,18 +87,25 @@ class FlacExporter(ExporterCore): def get_args(self,options=None): """Get process options and return arguments for the encoder""" - args = '' + args = [] if not options is None: self.options = options if not ('verbose' in self.options and self.options['verbose'] != '0'): - args = args + ' -s ' - + args.append('-s') if 'flac_quality' in self.options: - args = args+' -f -'+self.options['flac_quality'] + args.append('-f -' + self.options['flac_quality']) else: - args = args+' -f -'+self.quality_default + args.append('-f -' + self.quality_default) else: - args = args+' -s -f -'+self.quality_default + args.append('-s -f -' + self.quality_default) + + #for tag in self.metadata.keys(): + #value = clean_word(self.metadata[tag]) + #args.append('-c %s="%s"' % (tag, value)) + #if tag in self.dub2args_dict.keys(): + #arg = self.dub2args_dict[tag] + #args.append('-c %s="%s"' % (arg, value)) + return args def process(self, item_id, source, metadata, options=None): @@ -107,7 +114,9 @@ class FlacExporter(ExporterCore): self.metadata = metadata self.args = self.get_args(options) self.ext = self.get_file_extension() - self.command = 'flac '+self.args+' "'+self.source+'" -c -' + self.args = ' '.join(self.args) + self.command = 'flac %s "%s" -c -' \ + % (self.args, self.source) # Pre-proccessing self.dest = self.pre_process(self.item_id, diff --git a/telemeta/export/mp3.py b/telemeta/export/mp3.py index 72477415..4ff7d888 100644 --- a/telemeta/export/mp3.py +++ b/telemeta/export/mp3.py @@ -97,7 +97,7 @@ class Mp3Exporter(ExporterCore): id3.add(frame) id3.save() - def get_args(self, metadata, options=None): + def get_args(self, options=None): """Get process options and return arguments for the encoder""" args = [] if not options is None: @@ -114,12 +114,9 @@ class Mp3Exporter(ExporterCore): args.append('-S -c -o') for tag in self.metadata.keys(): - print tag if tag in self.dub2args_dict.keys(): arg = self.dub2args_dict[tag] - print arg value = clean_word(self.metadata[tag]) - print value args.append('--' + arg) args.append('"' + value + '"') @@ -129,7 +126,7 @@ class Mp3Exporter(ExporterCore): self.item_id = item_id self.source = source self.metadata = metadata - self.args = self.get_args(self.metadata,options) + self.args = self.get_args(options) self.ext = self.get_file_extension() self.args = ' '.join(self.args) self.command = 'sox "%s" -q -w -r 44100 -t wav -c2 - | lame %s -' \ diff --git a/telemeta/export/ogg.py b/telemeta/export/ogg.py index 6930b368..15260639 100644 --- a/telemeta/export/ogg.py +++ b/telemeta/export/ogg.py @@ -33,6 +33,9 @@ class OggExporter(ExporterCore): self.options = {} self.bitrate_default = '192' self.buffer_size = 0xFFFF + self.dub2args_dict = {'creator': 'artist', + 'relation': 'album' + } def get_format(self): return 'OGG' @@ -76,35 +79,39 @@ class OggExporter(ExporterCore): def get_args(self,options=None): """Get process options and return arguments for the encoder""" - args = '' + args = [] if not options is None: self.options = options - - if 'verbose' in self.options and self.options['verbose'] != '0': - args = args - else: - args = args + ' -Q ' - + if not ('verbose' in self.options and self.options['verbose'] != '0'): + args.append('-Q ') if 'ogg_bitrate' in self.options: - args = args + '-b '+self.options['ogg_bitrate'] + args.append('-b '+self.options['ogg_bitrate']) elif 'ogg_quality' in self.options: - args = args + '-q '+self.options['ogg_quality'] + args.append('-q '+self.options['ogg_quality']) else: - args = args + '-b '+self.bitrate_default + args.append('-b '+self.bitrate_default) else: - args = ' -Q -b '+self.bitrate_default + args.append('-Q -b '+self.bitrate_default) + + for tag in self.metadata.keys(): + value = clean_word(self.metadata[tag]) + args.append('-c %s="%s"' % (tag, value)) + if tag in self.dub2args_dict.keys(): + arg = self.dub2args_dict[tag] + args.append('-c %s="%s"' % (arg, value)) + return args - def process(self, item_id, source, metadata, options=None): self.item_id = item_id self.source = source self.metadata = metadata self.args = self.get_args(options) self.ext = self.get_file_extension() - self.command = 'sox "'+self.source+'" -q -w -r 44100 -t wav -c2 - '+ \ - '| oggenc '+self.args+' -' - + self.args = ' '.join(self.args) + self.command = 'sox "%s" -q -w -r 44100 -t wav -c2 - | oggenc %s -' \ + % (self.source,self.args) + # Pre-proccessing self.dest = self.pre_process(self.item_id, self.source,