audio: Make min duration in scanner configurable.

This commit is contained in:
Thomas Adamcik 2013-11-06 16:25:24 +01:00
parent 20b0602842
commit 16ac5277f6

View File

@ -13,8 +13,9 @@ from mopidy.models import Track, Artist, Album
class Scanner(object):
def __init__(self, timeout=1000):
def __init__(self, timeout=1000, min_duration=100):
self.timeout_ms = timeout
self.min_duration_ms = min_duration
sink = gst.element_factory_make('fakesink')
@ -42,10 +43,9 @@ class Scanner(object):
finally:
self._reset()
# TODO: this should be an option or just moved out.
if data[gst.TAG_DURATION] < 100:
raise exceptions.ScannerError(
'Rejecting file with less than 100ms audio data.')
if data[gst.TAG_DURATION] < self.min_duration_ms:
raise exceptions.ScannerError('Rejecting file with less than %dms '
'audio data.' % self.min_duration_ms)
return data
def _setup(self, uri):