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:
parent
8ba95b3587
commit
6501d563be
|
@ -474,6 +474,7 @@ def truncate_to_value(item, value):
|
||||||
return str(item)
|
return str(item)
|
||||||
|
|
||||||
def format_length(mutagen_length):
|
def format_length(mutagen_length):
|
||||||
|
if convert_format(mutagen_length):
|
||||||
""" Convert mutagen length to airtime length """
|
""" Convert mutagen length to airtime length """
|
||||||
t = float(mutagen_length)
|
t = float(mutagen_length)
|
||||||
h = int(math.floor(t / 3600))
|
h = int(math.floor(t / 3600))
|
||||||
|
@ -489,6 +490,13 @@ def format_length(mutagen_length):
|
||||||
else: ss = seconds[1][0:]
|
else: ss = seconds[1][0:]
|
||||||
return "%s:%s:%s.%s" % (h, m, s, ss)
|
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__':
|
if __name__ == '__main__':
|
||||||
import doctest
|
import doctest
|
||||||
doctest.testmod()
|
doctest.testmod()
|
||||||
|
|
Loading…
Reference in New Issue