diff --git a/python_apps/pypo/logging.cfg b/python_apps/pypo/logging.cfg index 234a094f0..3699d3dbf 100644 --- a/python_apps/pypo/logging.cfg +++ b/python_apps/pypo/logging.cfg @@ -1,5 +1,5 @@ [loggers] -keys=root,fetch,push,cue_file +keys=root,fetch,push [handlers] keys=fileOutHandler @@ -23,12 +23,6 @@ handlers=fileOutHandler qualname=push propagate=0 -[logger_cue_file] -level=DEBUG -handlers=fileOutHandler -qualname=push -propagate=0 - [handler_fileOutHandler] class=logging.handlers.RotatingFileHandler level=DEBUG diff --git a/python_apps/pypo/pypo-cli.py b/python_apps/pypo/pypo-cli.py index 8ececc23d..702ad8dd4 100755 --- a/python_apps/pypo/pypo-cli.py +++ b/python_apps/pypo/pypo-cli.py @@ -56,7 +56,6 @@ except Exception, e: class Global: def __init__(self): self.api_client = api_client.api_client_factory(config) - self.cue_file = CueFile() self.set_export_source('scheduler') def selfcheck(self): diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index 3100a5dd0..d9d78ddea 100755 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -59,7 +59,6 @@ class PypoFetch(Thread): Thread.__init__(self) logger = logging.getLogger('fetch') self.api_client = api_client.api_client_factory(config) - self.cue_file = CueFile() self.set_export_source('scheduler') self.queue = q logger.info("PypoFetch: init complete") diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index e867ebcfc..60dd4f522 100755 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -35,7 +35,6 @@ class PypoPush(Thread): def __init__(self, q): Thread.__init__(self) self.api_client = api_client.api_client_factory(config) - self.cue_file = CueFile() self.set_export_source('scheduler') self.queue = q diff --git a/python_apps/pypo/test/pypo-cue-in-validator.py b/python_apps/pypo/test/pypo-cue-in-validator.py deleted file mode 100755 index df4d06661..000000000 --- a/python_apps/pypo/test/pypo-cue-in-validator.py +++ /dev/null @@ -1,42 +0,0 @@ -import unittest - -from util.cue_file import CueFile - -from mutagen.mp3 import MP3 -from mutagen.oggvorbis import OggVorbis -import random -import string - -class test(unittest.TestCase): - - """ - - A test class for the cue_in module. - - """ - - def setUp(self): - self.cue_file = CueFile() - - def test_cue_mp3(self): - src = '../audio_samples/OpSound/Peter_Rudenko_-_Opening.mp3' - dst = '/tmp/' + "".join([random.choice(string.letters) for i in xrange(10)]) + '.mp3' - self.cue_file.cue(src, dst, 5, 5) - src_length = MP3(src).info.length - dst_length = MP3(dst).info.length - print src + " " + str(src_length) - print dst + " " + str(dst_length) - self.assertTrue(dst_length < src_length) - - def test_cue_ogg(self): - src = '../audio_samples/OpSound/ACDC_-_Back_In_Black-sample.ogg' - dst = '/tmp/' + "".join([random.choice(string.letters) for i in xrange(10)]) + '.ogg' - self.cue_file.cue(src, dst, 5, 5) - src_length = OggVorbis(src).info.length - dst_length = OggVorbis(dst).info.length - print src + " " + str(src_length) - print dst + " " + str(dst_length) - self.assertTrue(dst_length < src_length) - -if __name__ == '__main__': - unittest.main() diff --git a/python_apps/pypo/util/__init__.py b/python_apps/pypo/util/__init__.py index 692a4b4b1..afb963b43 100755 --- a/python_apps/pypo/util/__init__.py +++ b/python_apps/pypo/util/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- from json import * -from status import * -from cue_file import * \ No newline at end of file +from status import * \ No newline at end of file diff --git a/python_apps/pypo/util/cue_file.py b/python_apps/pypo/util/cue_file.py deleted file mode 100755 index 034515f23..000000000 --- a/python_apps/pypo/util/cue_file.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import sys -import shutil -import random -import string -import time -from datetime import timedelta -import os -import logging - -from mutagen.mp3 import MP3 -from mutagen.oggvorbis import OggVorbis - -class CueFile(): - - def __init__(self): - logger = logging.getLogger("cue_file") - logger.debug("init") - - def cue(self, src, dst, cue_in, cue_out): - - logger = logging.getLogger("cue_file") - logger.debug("cue file: %s %s %s %s", src, dst, cue_in, cue_out) - - if src.lower().endswith('.mp3'): - # mutagen - audio = MP3(src) - dur = round(audio.info.length, 3) - - logger.debug("duration by mutagen: %s", dur) - - cue_out = round(float(dur) - cue_out, 3) - - str_cue_in = str(timedelta(seconds=cue_in)).replace(".", "+") # hh:mm:ss+mss, eg 00:00:20+000 - str_cue_out = str(timedelta(seconds=cue_out)).replace(".", "+") # - - """ - now a bit a hackish part, don't know how to do this better... - need to cut the digits after the "+" - """ - ts = str_cue_in.split("+") - try: - if len(ts[1]) == 6: - ts[1] = ts[1][0:3] - str_cue_in = "%s+%s" % (ts[0], ts[1]) - except Exception, e: - pass - - ts = str_cue_out.split("+") - try: - if len(ts[1]) == 6: - ts[1] = ts[1][0:3] - str_cue_out = "%s+%s" % (ts[0], ts[1]) - except Exception, e: - pass - - logger.debug("in: %s", str_cue_in) - logger.debug("out: %s", str(str_cue_out) ) - - command = 'mp3cut -o %s -t %s-%s %s' % (dst + '.tmp.mp3', str_cue_in, str_cue_out, src); - logger.info("command: %s", command) - os.system(command + ' > /dev/null 2>&1') - - command = 'lame -b 128 %s %s' % (dst + '.tmp.mp3', dst); - logger.info("command: %s", command) - os.system(command + ' > /dev/null 2>&1') - elif src.lower().endswith('.ogg'): - audio = OggVorbis(src) - dur = audio.info.length - sys.stderr.write('duration: ' + str(dur) + '\n') - - cue_out = float(dur) - cue_out - - #convert input format of ss.mmm to milliseconds and to string< - str_cue_in = str(int(round(cue_in*1000))) - - #convert input format of ss.mmm to milliseconds and to string - str_cue_out = str(int(round(cue_out*1000))) - - command = 'oggCut -s %s -e %s %s %s' % (str_cue_in, str_cue_out, src, dst) - logger.info("command: %s", command) - os.system(command + ' > /dev/null 2>&1') - else: - logger.debug("in: %s", 'File name with invalid extension. File will not be cut\n') - - return dst