Handle file not found when scanning track

This commit is contained in:
Keith Edmunds 2024-11-01 11:47:38 +00:00
parent 2ce7f671ba
commit 3783996ba4

View File

@ -132,7 +132,11 @@ def get_audio_metadata(filepath: str) -> Dict[str, str | int | float]:
metadata: Dict[str, str | int | float] = {}
metadata["mtime"] = os.path.getmtime(filepath)
try:
metadata["mtime"] = os.path.getmtime(filepath)
except FileNotFoundError:
show_warning(None, "File not found", f"Filepath {filepath} not found")
return {}
# Set start_gap, fade_at and silence_at
audio = get_audio_segment(filepath)
@ -200,7 +204,10 @@ def get_tags(path: str) -> Dict[str, Any]:
Return a dictionary of title, artist, duration-in-milliseconds and path.
"""
tag = TinyTag.get(path)
try:
tag = TinyTag.get(path)
except FileNotFoundError:
return {}
return dict(
title=tag.title,