From 3107706d4d45ddd8c23359ed11c556b4ccbce316 Mon Sep 17 00:00:00 2001 From: yomguy <> Date: Wed, 23 May 2007 10:14:25 +0000 Subject: [PATCH] Fixed #26 partially for downloading but not for flash playing --- debian/control | 4 +++- telemeta/export/core.py | 27 +++++++++++++++++---------- telemeta/export/flac.py | 12 ++++++------ telemeta/export/mp3.py | 16 ++++++++-------- telemeta/export/ogg.py | 6 +++--- telemeta/export/wav.py | 2 +- 6 files changed, 38 insertions(+), 29 deletions(-) diff --git a/debian/control b/debian/control index 76cddaf4..4554d226 100644 --- a/debian/control +++ b/debian/control @@ -9,7 +9,9 @@ XS-Python-Version: >= 2.3 Package: telemeta Architecture: any -Depends: python (>= 2.3.5-7), python-xml, python-central (>= 0.5), python-mutagen, sox, vorbis-tools, flac, lame, normalize-audio, ecasound, festival, par2 +Depends: python (>= 2.3.5-7), python-xml, python-central (>= 0.5), +python-mutagen, python-django, sox, vorbis-tools, flac, lame, normalize-audio, +ecasound, festival, par2, python-mysqldb, sqlite3 | mysql-server XB-Python-Version: ${python:Versions} Description: backups, transcodes, tags and marks any audio content with metadata Telemeta is an audio tool which creates audio transcoded databases fast from diff --git a/telemeta/export/core.py b/telemeta/export/core.py index 8ad0fafe..e7666646 100644 --- a/telemeta/export/core.py +++ b/telemeta/export/core.py @@ -131,17 +131,20 @@ class ExporterCore(Component): # Define and create the destination path # At the moment, the target directory is built with this scheme in # the cache directory : ./%Format/%Collection/%Artist/ - self.dest = self.cache_dir + self.cache_dir = os.path.join(self.cache_dir,'cache') #export_dir = os.path.join(self.ext,self.collection,self.artist) - export_dir = self.ext - if not os.path.exists(os.path.join(self.dest,export_dir)): - for _dir in export_dir.split(os.sep): - self.dest = os.path.join(self.dest,_dir) - if not os.path.exists(self.dest): - os.mkdir(self.dest) + export_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 = export_dir_split[0] + for _dir in export_dir_split[1:]: + path = os.path.join(path,_dir) + if not os.path.exists(path): + os.mkdir(path) else: - self.dest = os.path.join(self.dest,export_dir) + self.dest = export_dir # Set the target file #target_file = file_name_wo_ext+'.'+self.ext @@ -259,13 +262,17 @@ def split_file_name(file): return 'Exporter error [1]: path does not exist.' def clean_word(word) : - """ Return the word without excessive blank spaces and underscores """ + """ Return the word without excessive blank spaces, underscores and + characters causing problem to exporters""" word = re.sub("^[^\w]+","",word) #trim the beginning word = re.sub("[^\w]+$","",word) #trim the end - #word = string.replace(word,' ','_') word = re.sub("_+","_",word) #squeeze continuous _ to one _ word = re.sub("^[^\w]+","",word) #trim the beginning _ + #word = string.replace(word,' ','_') #word = string.capitalize(word) + dict = '&[];"*' + for letter in dict: + word = string.replace(word,letter,'_') return word def recover_par_key(path): diff --git a/telemeta/export/flac.py b/telemeta/export/flac.py index 827aa26b..ddb9ad82 100644 --- a/telemeta/export/flac.py +++ b/telemeta/export/flac.py @@ -111,15 +111,15 @@ class FlacExporter(ExporterCore): '| flac '+self.args+' -c -' # Pre-proccessing - try: - self.dest = self.pre_process(self.item_id, + #try: + self.dest = self.pre_process(self.item_id, self.source, self.metadata, self.ext, self.cache_dir, self.options) - except: - yield 'ExporterError [3]: pre_process' + #except: + #raise 'ExporterError [3]: pre_process' # Processing (streaming + cache writing) try: @@ -127,7 +127,7 @@ class FlacExporter(ExporterCore): for chunk in stream: yield chunk except: - yield 'ExporterError: core_process' + raise 'ExporterError: core_process' # Post-proccessing try: @@ -138,7 +138,7 @@ class FlacExporter(ExporterCore): self.cache_dir, self.options) except: - yield 'ExporterError: post_process' + raise 'ExporterError: post_process' # Encoding diff --git a/telemeta/export/mp3.py b/telemeta/export/mp3.py index b56f5c10..0a0affa3 100644 --- a/telemeta/export/mp3.py +++ b/telemeta/export/mp3.py @@ -114,11 +114,11 @@ class Mp3Exporter(ExporterCore): 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 +'" ' + #for tag in self.metadata.keys(): + #if tag in self.dub2args_dict.keys(): + #arg = self.dub2args_dict[tag] + #value = clean_word(self.metadata[tag]) + #args = args + ' --' + arg + ' "' +value +'" ' return args @@ -140,7 +140,7 @@ class Mp3Exporter(ExporterCore): self.cache_dir, self.options) except: - yield 'ExporterError [3]: pre_process' + raise 'ExporterError [3]: pre_process' # Processing (streaming + cache writing) try: @@ -148,7 +148,7 @@ class Mp3Exporter(ExporterCore): for chunk in stream: yield chunk except: - yield 'ExporterError: core_process' + raise 'ExporterError: core_process' # Post-proccessing try: @@ -159,7 +159,7 @@ class Mp3Exporter(ExporterCore): self.cache_dir, self.options) except: - yield 'ExporterError: post_process' + raise 'ExporterError: post_process' # Encoding # os.system('lame '+args+' --tc "default" "'+self.source+ diff --git a/telemeta/export/ogg.py b/telemeta/export/ogg.py index 48ac7487..08e96607 100644 --- a/telemeta/export/ogg.py +++ b/telemeta/export/ogg.py @@ -114,7 +114,7 @@ class OggExporter(ExporterCore): self.cache_dir, self.options) except: - yield 'ExporterError [3]: pre_process' + raise 'ExporterError [3]: pre_process' # Processing (streaming + cache writing) try: @@ -122,7 +122,7 @@ class OggExporter(ExporterCore): for chunk in stream: yield chunk except: - yield 'ExporterError: core_process' + raise 'ExporterError: core_process' # Post-proccessing try: @@ -133,7 +133,7 @@ class OggExporter(ExporterCore): self.cache_dir, self.options) except: - yield 'ExporterError: post_process' + raise 'ExporterError: post_process' diff --git a/telemeta/export/wav.py b/telemeta/export/wav.py index 5bb15d71..3881787f 100644 --- a/telemeta/export/wav.py +++ b/telemeta/export/wav.py @@ -151,7 +151,7 @@ class WavExporter(ExporterCore): self.options) except IOError: - yield 'ExporterError [3]: source file does not exist.' + raise 'ExporterError [3]: source file does not exist.' -- 2.39.5