CC-5276: Adding watched folder throws exception sometimes

Fixed by only converting length format if it is not already in the correct format
This commit is contained in:
denise 2013-08-12 16:01:55 -04:00
parent 8ba95b3587
commit 6501d563be
1 changed files with 22 additions and 14 deletions

View File

@ -474,6 +474,7 @@ def truncate_to_value(item, value):
return str(item)
def format_length(mutagen_length):
if convert_format(mutagen_length):
""" Convert mutagen length to airtime length """
t = float(mutagen_length)
h = int(math.floor(t / 3600))
@ -489,6 +490,13 @@ def format_length(mutagen_length):
else: ss = seconds[1][0:]
return "%s:%s:%s.%s" % (h, m, s, ss)
def convert_format(value):
regCompiled = re.compile("^[0-9][0-9]:[0-9][0-9]:[0-9][0-9](\.\d+)?$")
if re.search(regCompiled, str(value)) is None:
return True
else:
return False
if __name__ == '__main__':
import doctest
doctest.testmod()