continue when invalid files found

if you have an invalid ogg file, ffprobe will exit!=0, so everything
will crash. This commit just ignores the file
This commit is contained in:
boyska 2020-11-16 15:30:02 +01:00
parent bddbbdf3ca
commit b7e0a7ace4

22
feed
View file

@ -238,15 +238,19 @@ def scan_dir_audio(dirname, extensions=("mp3", "oga", "wav", "ogg")):
def get_audio_from_dir(dirpath): def get_audio_from_dir(dirpath):
fpaths = scan_dir_audio(dirpath) fpaths = scan_dir_audio(dirpath)
return [ ret = []
Audio( for u in fpaths:
"file://" + os.path.realpath(u), try:
date=datetime.datetime.fromtimestamp(os.path.getmtime(u)).replace( a = Audio(
tzinfo=datetime.timezone.utc "file://" + os.path.realpath(u),
), date=datetime.datetime.fromtimestamp(os.path.getmtime(u)).replace(
) tzinfo=datetime.timezone.utc
for u in fpaths ),
] )
except ValueError:
continue
ret.append(a)
return ret
def get_item_date(el): def get_item_date(el):