From 6791d24a2c37abbb95375b6adde6932fa575579e Mon Sep 17 00:00:00 2001 From: boyska Date: Fri, 21 Feb 2014 18:42:25 +0100 Subject: [PATCH] filename of input and output are customizable the input filename can be customized, provided that the files still need to be cut hourly --- server/default_config.py | 2 ++ server/forge.py | 6 +++--- server/server.py | 7 ++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/server/default_config.py b/server/default_config.py index 8d923d6..6ac7d9b 100644 --- a/server/default_config.py +++ b/server/default_config.py @@ -5,5 +5,7 @@ DEBUG = True DB_URI = 'sqlite:///techrec.db' AUDIO_OUTPUT = 'output/' AUDIO_INPUT = 'rec/' +AUDIO_INPUT_FORMAT = '%Y-%m/%d/rec-%Y-%m-%d-%H-%M-%S.mp3' +AUDIO_OUTPUT_FORMAT = 'techrec-%(time)s-%(name)s' FORGE_TIMEOUT = 20 FORGE_MAX_DURATION = 3600*5 diff --git a/server/forge.py b/server/forge.py index d81026e..2e2c84c 100644 --- a/server/forge.py +++ b/server/forge.py @@ -13,9 +13,9 @@ def get_timefile_exact(time): that work is done in get_timefile(time) ''' return os.path.join( - get_config()['AUDIO_INPUT'], - time.strftime('%Y-%m/%d/rec-%Y-%m-%d-%H-%M-%S-ror.mp3') - ) + get_config()['AUDIO_INPUT'], + time.strftime(get_config()['AUDIO_INPUT_FORMAT']) + ) def round_timefile(exact): diff --git a/server/server.py b/server/server.py index 9606684..609304c 100644 --- a/server/server.py +++ b/server/server.py @@ -152,9 +152,10 @@ class RecAPI(Bottle): ' (%d seconds)' % (rec.endtime - rec.starttime).total_seconds() } - rec.filename = 'ror-%s-%s.mp3' % \ - (rec.starttime.strftime('%y%m%d_%H%M'), - filter(lambda c: c.isalpha(), rec.name)) + rec.filename = get_config()['AUDIO_OUTPUT_FORMAT'] % { + 'time': rec.starttime.strftime('%y%m%d_%H%M'), + 'name': filter(lambda c: c.isalpha(), rec.name) + } self.db.update(rec.id, rec.serialize()) job_id = get_process_queue().submit( create_mp3,