sane-tag-music: don't crash when file opening fails

This commit is contained in:
Colin 2023-12-07 15:51:51 +00:00
parent fc4803f3fd
commit 2c66d8cad0

View File

@ -184,15 +184,18 @@ class Tags:
class AudioFile:
def __init__(self, path_: str):
self.path_ = path_
self.muta = None
_base, ext = os.path.splitext(path_)
if ext == '.flac':
self.muta = mutagen.flac.Open(path_)
elif ext == '.mp3':
self.muta = mutagen.easyid3.EasyID3(path_)
else:
logger.debug(f"no metadata handler for {path_}")
self.muta = None
try:
if ext == '.flac':
self.muta = mutagen.flac.Open(path_)
elif ext == '.mp3':
self.muta = mutagen.easyid3.EasyID3(path_)
else:
logger.debug(f"no metadata handler for {path_}")
except Exception as e:
logger.warning(f"failed to open {path_}: {e}")
@staticmethod
def new(path_: str) -> 'AudioFile':