From: yomguy Date: Wed, 7 Oct 2009 13:43:08 +0000 (+0000) Subject: rename decode and encode cores X-Git-Tag: 0.3.2~248 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=dfa95b513361d31d3c144f3a3060ba75e7b08ef1;p=timeside.git rename decode and encode cores --- diff --git a/decode/__init__.py b/decode/__init__.py index 06cb43a..5af60e5 100644 --- a/decode/__init__.py +++ b/decode/__init__.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -from timeside.export.api import * -from timeside.export.core import * -from timeside.export.ogg import * -from timeside.export.flac import * -from timeside.export.wav import * -from timeside.export.mp3 import * \ No newline at end of file +from timeside.decode.api import * +from timeside.decode.core import * +from timeside.decode.ogg import * +from timeside.decode.flac import * +from timeside.decode.wav import * +from timeside.decode.mp3 import * \ No newline at end of file diff --git a/decode/api.py b/decode/api.py index 7ee861c..61f5f87 100644 --- a/decode/api.py +++ b/decode/api.py @@ -21,8 +21,8 @@ from timeside.core import Interface, TimeSideError -class IExporter(Interface): - """Export driver interface""" +class IDecoder(Interface): + """Decoder driver interface""" # Remark: the method prototypes do not include any self or cls argument # because an interface is meant to show what methods a class must expose @@ -30,39 +30,37 @@ class IExporter(Interface): # you'll obviously want to include this extra argument. def get_format(): - """Return the export/encoding format as a short string + """Return the decode/encoding format as a short string Example: "MP3", "OGG", "AVI", ... """ def get_description(): - """Return a string describing what this export format provides, is good + """Return a string describing what this decode format provides, is good for, etc... The description is meant to help the end user decide what format is good for him/her """ def get_file_extension(): - """Return the filename extension corresponding to this export format""" + """Return the filename extension corresponding to this decode format""" def get_mime_type(): - """Return the mime type corresponding to this export format""" + """Return the mime type corresponding to this decode format""" def set_cache_dir(path): """Set the directory where cached files should be stored. Does nothing - if the exporter doesn't support caching. + if the decodeer 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. """ def process(item_id, source, metadata, options=None): - """Perform the exporting process and return the absolute path - to the resulting file. + """Perform the decoding process and stream the result through a generator item_id is the media item id that uniquely identifies this audio/video resource - source is the audio/video source file absolute path. For audio that - should be a WAV file + source is the audio/video source file absolute path. metadata is a tuple containing tuples for each descriptor return by the dc.Ressource of the item, in the model order : @@ -71,14 +69,14 @@ class IExporter(Interface): The returned file path is not meant to be permanent in any way, it should be considered temporary/volatile by the caller. - It is highly recommended that export drivers implement some sort of + It is highly recommended that decode drivers implement some sort of cache instead of re-encoding each time process() is called. It should be possible to make subsequent calls to process() with different items, using the same driver instance. """ -class ExportProcessError(TimeSideError): +class DecodeProcessError(TimeSideError): def __init__(self, message, command, subprocess): self.message = message diff --git a/decode/core.py b/decode/core.py index 6f83356..8e6874b 100644 --- a/decode/core.py +++ b/decode/core.py @@ -27,13 +27,13 @@ import string import subprocess import mutagen -from timeside.export import * +from timeside.decode import * from timeside.core import * import xml.dom.minidom import xml.dom.ext -class ExporterCore(Component): - """Defines the main parts of the exporting tools : +class DecoderCore(Component): + """Defines the main parts of the decodeing tools : paths, metadata parsing, data streaming thru system command""" def __init__(self): @@ -57,7 +57,7 @@ class ExporterCore(Component): os.system('normalize-audio '+args+' "'+self.source+'"') return self.source except: - raise IOError('ExporterError: cannot normalize, path does not exist.') + raise IOError('DecoderError: cannot normalize, path does not exist.') def check_md5_key(self): """ Check if the md5 key is OK and return a boolean """ @@ -66,11 +66,11 @@ class ExporterCore(Component): '" "'+self.dest+'.md5"') return 'OK' in md5_log.split(':') except IOError: - raise IOError('ExporterError: cannot check the md5 key.') + raise IOError('DecoderError: cannot check the md5 key.') def get_file_info(self): """ Return the list of informations of the dest """ - return self.export.get_file_info() + return self.decode.get_file_info() def get_wav_length_sec(self) : """ Return the length of the audio source file in seconds """ @@ -82,7 +82,7 @@ class ExporterCore(Component): value = int(int(line_split[1])/(4*44100)) return value except: - raise IOError('ExporterError: cannot get the wav length.') + raise IOError('DecoderError: cannot get the wav length.') def compare_md5_key(self, source, dest): """ Compare source and dest files wih md5 method """ @@ -106,7 +106,7 @@ class ExporterCore(Component): def pre_process(self, item_id, source, metadata, ext, cache_dir, options=None): - """ Pre processing : prepare the export path and return it""" + """ Pre processing : prepare the decode path and return it""" self.item_id = str(item_id) self.source = source file_name = get_file_name(self.source) @@ -124,19 +124,19 @@ class ExporterCore(Component): self.options['normalize'] == True: self.normalize() - # Define the export directory + # Define the decode directory self.ext = self.get_file_extension() - export_dir = os.path.join(self.cache_dir,self.ext) + decode_dir = os.path.join(self.cache_dir,self.ext) - if not os.path.exists(export_dir): - export_dir_split = export_dir.split(os.sep) - path = os.sep + export_dir_split[0] - for _dir in export_dir_split[1:]: + if not os.path.exists(decode_dir): + decode_dir_split = decode_dir.split(os.sep) + path = os.sep + decode_dir_split[0] + for _dir in decode_dir_split[1:]: path = os.path.join(path,_dir) if not os.path.exists(path): os.mkdir(path) else: - path = export_dir + path = decode_dir # Set the target file target_file = self.item_id+'.'+self.ext @@ -212,7 +212,7 @@ def get_file_mime_type(path): mime = line_split[len(line_split)-1] return mime[:len(mime)-1] except: - raise IOError('ExporterError: path does not exist.') + raise IOError('DecoderError: path does not exist.') def get_file_type_desc(path): """ Return the type of a file given by the 'file' command """ @@ -223,7 +223,7 @@ def get_file_type_desc(path): description = description[1].split(', ') return description except: - raise IOError('ExporterError: path does not exist.') + raise IOError('DecoderError: path does not exist.') def iswav(path): """ Tell if path is a WAV """ @@ -231,7 +231,7 @@ def iswav(path): mime = get_file_mime_type(path) return mime == 'audio/x-wav' except: - raise IOError('ExporterError: path does not exist.') + raise IOError('DecoderError: path does not exist.') def iswav16(path): """ Tell if path is a 16 bit WAV """ @@ -239,7 +239,7 @@ def iswav16(path): file_type_desc = get_file_type_desc(path) return iswav(path) and '16 bit' in file_type_desc except: - raise IOError('ExporterError: path does not exist.') + raise IOError('DecoderError: path does not exist.') def get_file_name(path): """ Return the file name targeted in the path """ @@ -250,11 +250,11 @@ def split_file_name(file): try: return os.path.splitext(file) except: - raise IOError('ExporterError: path does not exist.') + raise IOError('DecoderError: path does not exist.') def clean_word(word) : """ Return the word without excessive blank spaces, underscores and - characters causing problem to exporters""" + characters causing problem to decodeers""" word = re.sub("^[^\w]+","",word) #trim the beginning word = re.sub("[^\w]+$","",word) #trim the end word = re.sub("_+","_",word) #squeeze continuous _ to one _ diff --git a/decode/flac.py b/decode/flac.py index 60f2f92..37b956e 100644 --- a/decode/flac.py +++ b/decode/flac.py @@ -23,15 +23,15 @@ import os import string import subprocess -from timeside.export.core import * -from timeside.export.api import IExporter +from timeside.decode.core import * +from timeside.decode.api import IDecoder from mutagen.flac import FLAC from tempfile import NamedTemporaryFile -class FlacExporter(ExporterCore): - """Defines methods to export to FLAC""" +class FlacDecoder(DecoderCore): + """Defines methods to decode to FLAC""" - implements(IExporter) + implements(IDecoder) def __init__(self): self.item_id = '' @@ -65,12 +65,12 @@ class FlacExporter(ExporterCore): self.info = info return self.info except: - raise IOError('ExporterError: metaflac is not installed or ' + \ + raise IOError('DecoderError: metaflac is not installed or ' + \ 'file does not exist.') 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 decodeer 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. @@ -85,7 +85,7 @@ class FlacExporter(ExporterCore): self.source = dest return dest except: - raise IOError('ExporterError: decoder is not compatible.') + raise IOError('DecoderError: decoder is not compatible.') def write_tags(self, file): media = FLAC(file) @@ -99,7 +99,7 @@ class FlacExporter(ExporterCore): try: media.save() except: - raise IOError('ExporterError: cannot write tags.') + raise IOError('DecoderError: cannot write tags.') def get_args(self,options=None): """Get process options and return arguments for the encoder""" diff --git a/decode/mp3.py b/decode/mp3.py index e75f15f..b89a924 100644 --- a/decode/mp3.py +++ b/decode/mp3.py @@ -24,14 +24,14 @@ import os import string import subprocess -from timeside.export.core import * -from timeside.export.api import IExporter +from timeside.decode.core import * +from timeside.decode.api import IDecoder #from mutagen.id3 import * -class Mp3Exporter(ExporterCore): - """Defines methods to export to MP3""" +class Mp3Decoder(DecoderCore): + """Defines methods to decode to MP3""" - implements(IExporter) + implements(IDecoder) def __init__(self): self.item_id = '' @@ -83,7 +83,7 @@ class Mp3Exporter(ExporterCore): self.info = info return self.info except: - raise IOError('ExporterError: file does not exist.') + raise IOError('DecoderError: file does not exist.') def decode(self): try: @@ -91,7 +91,7 @@ class Mp3Exporter(ExporterCore): +self.cache_dir+os.sep+self.item_id+'"') return self.cache_dir+os.sep+self.item_id+'.wav' except: - raise IOError('ExporterError: decoder is not compatible.') + raise IOError('DecoderError: decoder is not compatible.') def write_tags(self): """Write all ID3v2.4 tags by mapping dub2id3_dict dictionnary with the @@ -106,11 +106,11 @@ class Mp3Exporter(ExporterCore): try: id3.add(frame) except: - raise IOError('ExporterError: cannot tag "'+tag+'"') + raise IOError('DecoderError: cannot tag "'+tag+'"') try: id3.save() except: - raise IOError('ExporterError: cannot write tags') + raise IOError('DecoderError: cannot write tags') def get_args(self, options=None): """Get process options and return arguments for the encoder""" diff --git a/decode/ogg.py b/decode/ogg.py index 270449a..278e089 100644 --- a/decode/ogg.py +++ b/decode/ogg.py @@ -23,14 +23,14 @@ import os import string import subprocess -from timeside.export.core import * -from timeside.export.api import IExporter +from timeside.decode.core import * +from timeside.decode.api import IDecoder from mutagen.oggvorbis import OggVorbis -class OggExporter(ExporterCore): - """Defines methods to export to OGG Vorbis""" +class OggDecoder(DecoderCore): + """Defines methods to decode to OGG Vorbis""" - implements(IExporter) + implements(IDecoder) def __init__(self): self.item_id = '' @@ -67,7 +67,7 @@ class OggExporter(ExporterCore): self.info = info return self.info except: - raise IOError('ExporterError: file does not exist.') + raise IOError('DecoderError: file does not exist.') def set_cache_dir(self,path): self.cache_dir = path @@ -78,7 +78,7 @@ class OggExporter(ExporterCore): '.wav" "'+self.source+'"') return self.cache_dir+os.sep+self.item_id+'.wav' except: - raise IOError('ExporterError: decoder is not compatible.') + raise IOError('DecoderError: decoder is not compatible.') def write_tags(self): media = OggVorbis(self.dest) diff --git a/decode/wav.py b/decode/wav.py index c98a172..87a64ad 100644 --- a/decode/wav.py +++ b/decode/wav.py @@ -22,13 +22,13 @@ import os import string -from timeside.export.core import * -from timeside.export.api import IExporter +from timeside.decode.core import * +from timeside.decode.api import IDecoder -class WavExporter(ExporterCore): - """Defines methods to export to WAV""" +class WavDecoder(DecoderCore): + """Defines methods to decode to WAV""" - implements(IExporter) + implements(IDecoder) def __init__(self): self.item_id = '' @@ -61,7 +61,7 @@ class WavExporter(ExporterCore): self.info = info return self.info except: - raise IOError('ExporterError: wavinfo id not installed or file does not exist.') + raise IOError('DecoderError: wavinfo id not installed or file does not exist.') def set_cache_dir(self,path): self.cache_dir = path @@ -75,7 +75,7 @@ class WavExporter(ExporterCore): self.source = dest return dest except: - raise IOError('ExporterError: decoder is not compatible.') + raise IOError('DecoderError: decoder is not compatible.') def write_tags(self): # Create metadata XML file ! @@ -86,7 +86,7 @@ class WavExporter(ExporterCore): try: os.system('md5sum -b "'+self.dest+'" >"'+self.dest+'.md5"') except: - raise IOError('ExporterError: cannot create the md5 key.') + raise IOError('DecoderError: cannot create the md5 key.') def create_par_key(self): """ Create the par2 keys of the dest """ @@ -99,7 +99,7 @@ class WavExporter(ExporterCore): try: os.system('par2 '+args+' "'+self.dest+'"') except: - raise IOError('ExporterError: cannot create the par2 key.') + raise IOError('DecoderError: cannot create the par2 key.') def process(self, item_id, source, metadata, options=None): self.item_id = item_id diff --git a/encode/__init__.py b/encode/__init__.py index 06cb43a..cfed4ed 100644 --- a/encode/__init__.py +++ b/encode/__init__.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -from timeside.export.api import * -from timeside.export.core import * -from timeside.export.ogg import * -from timeside.export.flac import * -from timeside.export.wav import * -from timeside.export.mp3 import * \ No newline at end of file +from timeside.encode.api import * +from timeside.encode.core import * +from timeside.encode.ogg import * +from timeside.encode.flac import * +from timeside.encode.wav import * +from timeside.encode.mp3 import * \ No newline at end of file diff --git a/encode/api.py b/encode/api.py index 7ee861c..b97edca 100644 --- a/encode/api.py +++ b/encode/api.py @@ -21,8 +21,8 @@ from timeside.core import Interface, TimeSideError -class IExporter(Interface): - """Export driver interface""" +class IEncoder(Interface): + """Encoder driver interface""" # Remark: the method prototypes do not include any self or cls argument # because an interface is meant to show what methods a class must expose @@ -30,39 +30,37 @@ class IExporter(Interface): # you'll obviously want to include this extra argument. def get_format(): - """Return the export/encoding format as a short string + """Return the encode/encoding format as a short string Example: "MP3", "OGG", "AVI", ... """ def get_description(): - """Return a string describing what this export format provides, is good + """Return a string describing what this encode format provides, is good for, etc... The description is meant to help the end user decide what format is good for him/her """ def get_file_extension(): - """Return the filename extension corresponding to this export format""" + """Return the filename extension corresponding to this encode format""" def get_mime_type(): - """Return the mime type corresponding to this export format""" + """Return the mime type corresponding to this encode format""" def set_cache_dir(path): """Set the directory where cached files should be stored. Does nothing - if the exporter doesn't support caching. + if the encodeer 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. """ def process(item_id, source, metadata, options=None): - """Perform the exporting process and return the absolute path - to the resulting file. + """Perform the encoding process and stream the result as a generator. item_id is the media item id that uniquely identifies this audio/video resource - source is the audio/video source file absolute path. For audio that - should be a WAV file + source is a raw audio stream coming from the decoder. metadata is a tuple containing tuples for each descriptor return by the dc.Ressource of the item, in the model order : @@ -71,7 +69,7 @@ class IExporter(Interface): The returned file path is not meant to be permanent in any way, it should be considered temporary/volatile by the caller. - It is highly recommended that export drivers implement some sort of + It is highly recommended that encode drivers implement some sort of cache instead of re-encoding each time process() is called. It should be possible to make subsequent calls to process() with diff --git a/encode/core.py b/encode/core.py index 6f83356..00f428a 100644 --- a/encode/core.py +++ b/encode/core.py @@ -27,13 +27,13 @@ import string import subprocess import mutagen -from timeside.export import * +from timeside.encode import * from timeside.core import * import xml.dom.minidom import xml.dom.ext -class ExporterCore(Component): - """Defines the main parts of the exporting tools : +class EncoderCore(Component): + """Defines the main parts of the encodeing tools : paths, metadata parsing, data streaming thru system command""" def __init__(self): @@ -57,7 +57,7 @@ class ExporterCore(Component): os.system('normalize-audio '+args+' "'+self.source+'"') return self.source except: - raise IOError('ExporterError: cannot normalize, path does not exist.') + raise IOError('EncoderError: cannot normalize, path does not exist.') def check_md5_key(self): """ Check if the md5 key is OK and return a boolean """ @@ -66,11 +66,11 @@ class ExporterCore(Component): '" "'+self.dest+'.md5"') return 'OK' in md5_log.split(':') except IOError: - raise IOError('ExporterError: cannot check the md5 key.') + raise IOError('EncoderError: cannot check the md5 key.') def get_file_info(self): """ Return the list of informations of the dest """ - return self.export.get_file_info() + return self.encode.get_file_info() def get_wav_length_sec(self) : """ Return the length of the audio source file in seconds """ @@ -82,7 +82,7 @@ class ExporterCore(Component): value = int(int(line_split[1])/(4*44100)) return value except: - raise IOError('ExporterError: cannot get the wav length.') + raise IOError('EncoderError: cannot get the wav length.') def compare_md5_key(self, source, dest): """ Compare source and dest files wih md5 method """ @@ -106,7 +106,7 @@ class ExporterCore(Component): def pre_process(self, item_id, source, metadata, ext, cache_dir, options=None): - """ Pre processing : prepare the export path and return it""" + """ Pre processing : prepare the encode path and return it""" self.item_id = str(item_id) self.source = source file_name = get_file_name(self.source) @@ -124,19 +124,19 @@ class ExporterCore(Component): self.options['normalize'] == True: self.normalize() - # Define the export directory + # Define the encode directory self.ext = self.get_file_extension() - export_dir = os.path.join(self.cache_dir,self.ext) + encode_dir = os.path.join(self.cache_dir,self.ext) - if not os.path.exists(export_dir): - export_dir_split = export_dir.split(os.sep) - path = os.sep + export_dir_split[0] - for _dir in export_dir_split[1:]: + if not os.path.exists(encode_dir): + encode_dir_split = encode_dir.split(os.sep) + path = os.sep + encode_dir_split[0] + for _dir in encode_dir_split[1:]: path = os.path.join(path,_dir) if not os.path.exists(path): os.mkdir(path) else: - path = export_dir + path = encode_dir # Set the target file target_file = self.item_id+'.'+self.ext @@ -212,7 +212,7 @@ def get_file_mime_type(path): mime = line_split[len(line_split)-1] return mime[:len(mime)-1] except: - raise IOError('ExporterError: path does not exist.') + raise IOError('EncoderError: path does not exist.') def get_file_type_desc(path): """ Return the type of a file given by the 'file' command """ @@ -223,7 +223,7 @@ def get_file_type_desc(path): description = description[1].split(', ') return description except: - raise IOError('ExporterError: path does not exist.') + raise IOError('EncoderError: path does not exist.') def iswav(path): """ Tell if path is a WAV """ @@ -231,7 +231,7 @@ def iswav(path): mime = get_file_mime_type(path) return mime == 'audio/x-wav' except: - raise IOError('ExporterError: path does not exist.') + raise IOError('EncoderError: path does not exist.') def iswav16(path): """ Tell if path is a 16 bit WAV """ @@ -239,7 +239,7 @@ def iswav16(path): file_type_desc = get_file_type_desc(path) return iswav(path) and '16 bit' in file_type_desc except: - raise IOError('ExporterError: path does not exist.') + raise IOError('EncoderError: path does not exist.') def get_file_name(path): """ Return the file name targeted in the path """ @@ -250,11 +250,11 @@ def split_file_name(file): try: return os.path.splitext(file) except: - raise IOError('ExporterError: path does not exist.') + raise IOError('EncoderError: path does not exist.') def clean_word(word) : """ Return the word without excessive blank spaces, underscores and - characters causing problem to exporters""" + characters causing problem to encodeers""" word = re.sub("^[^\w]+","",word) #trim the beginning word = re.sub("[^\w]+$","",word) #trim the end word = re.sub("_+","_",word) #squeeze continuous _ to one _ diff --git a/encode/flac.py b/encode/flac.py index 60f2f92..e655390 100644 --- a/encode/flac.py +++ b/encode/flac.py @@ -23,15 +23,15 @@ import os import string import subprocess -from timeside.export.core import * -from timeside.export.api import IExporter +from timeside.encode.core import * +from timeside.encode.api import IEncoder from mutagen.flac import FLAC from tempfile import NamedTemporaryFile -class FlacExporter(ExporterCore): - """Defines methods to export to FLAC""" +class FlacEncoder(EncoderCore): + """Defines methods to encode to FLAC""" - implements(IExporter) + implements(IEncoder) def __init__(self): self.item_id = '' @@ -65,12 +65,12 @@ class FlacExporter(ExporterCore): self.info = info return self.info except: - raise IOError('ExporterError: metaflac is not installed or ' + \ + raise IOError('EncoderError: metaflac is not installed or ' + \ 'file does not exist.') 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 encodeer 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. @@ -85,7 +85,7 @@ class FlacExporter(ExporterCore): self.source = dest return dest except: - raise IOError('ExporterError: decoder is not compatible.') + raise IOError('EncoderError: decoder is not compatible.') def write_tags(self, file): media = FLAC(file) @@ -99,7 +99,7 @@ class FlacExporter(ExporterCore): try: media.save() except: - raise IOError('ExporterError: cannot write tags.') + raise IOError('EncoderError: cannot write tags.') def get_args(self,options=None): """Get process options and return arguments for the encoder""" diff --git a/encode/mp3.py b/encode/mp3.py index e75f15f..0b4fa38 100644 --- a/encode/mp3.py +++ b/encode/mp3.py @@ -24,14 +24,14 @@ import os import string import subprocess -from timeside.export.core import * -from timeside.export.api import IExporter +from timeside.encode.core import * +from timeside.encode.api import IEncoder #from mutagen.id3 import * -class Mp3Exporter(ExporterCore): - """Defines methods to export to MP3""" +class Mp3Encoder(EencoderCore): + """Defines methods to encode to MP3""" - implements(IExporter) + implements(IEncoder) def __init__(self): self.item_id = '' @@ -83,7 +83,7 @@ class Mp3Exporter(ExporterCore): self.info = info return self.info except: - raise IOError('ExporterError: file does not exist.') + raise IOError('EncoderError: file does not exist.') def decode(self): try: @@ -91,7 +91,7 @@ class Mp3Exporter(ExporterCore): +self.cache_dir+os.sep+self.item_id+'"') return self.cache_dir+os.sep+self.item_id+'.wav' except: - raise IOError('ExporterError: decoder is not compatible.') + raise IOError('EncoderError: decoder is not compatible.') def write_tags(self): """Write all ID3v2.4 tags by mapping dub2id3_dict dictionnary with the @@ -106,11 +106,11 @@ class Mp3Exporter(ExporterCore): try: id3.add(frame) except: - raise IOError('ExporterError: cannot tag "'+tag+'"') + raise IOError('EncoderError: cannot tag "'+tag+'"') try: id3.save() except: - raise IOError('ExporterError: cannot write tags') + raise IOError('EncoderError: cannot write tags') def get_args(self, options=None): """Get process options and return arguments for the encoder""" diff --git a/encode/ogg.py b/encode/ogg.py index 270449a..7437ac7 100644 --- a/encode/ogg.py +++ b/encode/ogg.py @@ -23,14 +23,14 @@ import os import string import subprocess -from timeside.export.core import * -from timeside.export.api import IExporter +from timeside.encode.core import * +from timeside.encode.api import IEncoder from mutagen.oggvorbis import OggVorbis -class OggExporter(ExporterCore): - """Defines methods to export to OGG Vorbis""" +class OggEncoder(EncoderCore): + """Defines methods to encode to OGG Vorbis""" - implements(IExporter) + implements(IEncoder) def __init__(self): self.item_id = '' @@ -67,7 +67,7 @@ class OggExporter(ExporterCore): self.info = info return self.info except: - raise IOError('ExporterError: file does not exist.') + raise IOError('EncoderError: file does not exist.') def set_cache_dir(self,path): self.cache_dir = path @@ -78,7 +78,7 @@ class OggExporter(ExporterCore): '.wav" "'+self.source+'"') return self.cache_dir+os.sep+self.item_id+'.wav' except: - raise IOError('ExporterError: decoder is not compatible.') + raise IOError('EncoderError: decoder is not compatible.') def write_tags(self): media = OggVorbis(self.dest) diff --git a/encode/wav.py b/encode/wav.py index c98a172..b1e822c 100644 --- a/encode/wav.py +++ b/encode/wav.py @@ -22,13 +22,13 @@ import os import string -from timeside.export.core import * -from timeside.export.api import IExporter +from timeside.encode.core import * +from timeside.encode.api import IEncoder -class WavExporter(ExporterCore): - """Defines methods to export to WAV""" +class WavEncoder(EncoderCore): + """Defines methods to encode to WAV""" - implements(IExporter) + implements(IEncoder) def __init__(self): self.item_id = '' @@ -61,7 +61,7 @@ class WavExporter(ExporterCore): self.info = info return self.info except: - raise IOError('ExporterError: wavinfo id not installed or file does not exist.') + raise IOError('EncoderError: wavinfo id not installed or file does not exist.') def set_cache_dir(self,path): self.cache_dir = path @@ -75,7 +75,7 @@ class WavExporter(ExporterCore): self.source = dest return dest except: - raise IOError('ExporterError: decoder is not compatible.') + raise IOError('EncoderError: decoder is not compatible.') def write_tags(self): # Create metadata XML file ! @@ -86,7 +86,7 @@ class WavExporter(ExporterCore): try: os.system('md5sum -b "'+self.dest+'" >"'+self.dest+'.md5"') except: - raise IOError('ExporterError: cannot create the md5 key.') + raise IOError('EncoderError: cannot create the md5 key.') def create_par_key(self): """ Create the par2 keys of the dest """ @@ -99,7 +99,7 @@ class WavExporter(ExporterCore): try: os.system('par2 '+args+' "'+self.dest+'"') except: - raise IOError('ExporterError: cannot create the par2 key.') + raise IOError('EncoderError: cannot create the par2 key.') def process(self, item_id, source, metadata, options=None): self.item_id = item_id