diff --git a/python_apps/media-monitor2/media/monitor/metadata.py b/python_apps/media-monitor2/media/monitor/metadata.py index b62f72c09..c935e0667 100644 --- a/python_apps/media-monitor2/media/monitor/metadata.py +++ b/python_apps/media-monitor2/media/monitor/metadata.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- import mutagen -import math import os import copy from collections import namedtuple @@ -8,6 +7,7 @@ from mutagen.easymp4 import EasyMP4KeyError from media.monitor.exceptions import BadSongFile from media.monitor.log import Loggable +from media.monitor.pure import format_length import media.monitor.pure as mmp """ @@ -94,24 +94,6 @@ truncate_table = { 'MDATA_KEY_COPYRIGHT' : 512, } -def format_length(mutagen_length): - """ - Convert mutagen length to airtime length - """ - t = float(mutagen_length) - h = int(math.floor(t / 3600)) - t = t % 3600 - m = int(math.floor(t / 60)) - s = t % 60 - # will be ss.uuu - s = str(s) - seconds = s.split(".") - s = seconds[0] - # have a maximum of 6 subseconds. - if len(seconds[1]) >= 6: ss = seconds[1][0:6] - else: ss = seconds[1][0:] - return "%s:%s:%s.%s" % (h, m, s, ss) - def truncate_to_length(item, length): if isinstance(item, int): item = str(item) if isinstance(item, basestring): diff --git a/python_apps/media-monitor2/media/monitor/pure.py b/python_apps/media-monitor2/media/monitor/pure.py index b8f3b4c12..4c607d1c2 100644 --- a/python_apps/media-monitor2/media/monitor/pure.py +++ b/python_apps/media-monitor2/media/monitor/pure.py @@ -308,6 +308,7 @@ def organized_path(old_path, root_path, orig_md): # MDATA_KEY_BITRATE is in bytes/second i.e. (256000) we want to turn this # into 254kbps + # Some metadata elements cannot be empty, hence we default them to some # value just so that we can create a correct path normal_md = default_to_f(orig_md, path_md, unicode_unknown, default_f) @@ -477,12 +478,12 @@ def file_playable(pathname): """ Returns True if 'pathname' is playable by liquidsoap. False otherwise. """ - #when there is an single apostrophe inside of a string quoted by - #apostrophes, we can only escape it by replace that apostrophe with '\''. - #This breaks the string into two, and inserts an escaped single quote in - #between them. We run the command as pypo because otherwise the target file - #is opened with write permissions, and this causes an inotify ON_CLOSE_WRITE - #event to be fired :/ + # when there is an single apostrophe inside of a string quoted by + # apostrophes, we can only escape it by replace that apostrophe with + # '\''. This breaks the string into two, and inserts an escaped + # single quote in between them. We run the command as pypo because + # otherwise the target file is opened with write permissions, and + # this causes an inotify ON_CLOSE_WRITE event to be fired :/ command = ("airtime-liquidsoap -c 'output.dummy" + \ "(audio_to_stereo(single(\"%s\")))' > /dev/null 2>&1") % \ pathname.replace("'", "'\\''")