sane-tag-music: don't crash when file opening fails
This commit is contained in:
@@ -184,15 +184,18 @@ class Tags:
|
|||||||
class AudioFile:
|
class AudioFile:
|
||||||
def __init__(self, path_: str):
|
def __init__(self, path_: str):
|
||||||
self.path_ = path_
|
self.path_ = path_
|
||||||
|
self.muta = None
|
||||||
|
|
||||||
_base, ext = os.path.splitext(path_)
|
_base, ext = os.path.splitext(path_)
|
||||||
if ext == '.flac':
|
try:
|
||||||
self.muta = mutagen.flac.Open(path_)
|
if ext == '.flac':
|
||||||
elif ext == '.mp3':
|
self.muta = mutagen.flac.Open(path_)
|
||||||
self.muta = mutagen.easyid3.EasyID3(path_)
|
elif ext == '.mp3':
|
||||||
else:
|
self.muta = mutagen.easyid3.EasyID3(path_)
|
||||||
logger.debug(f"no metadata handler for {path_}")
|
else:
|
||||||
self.muta = None
|
logger.debug(f"no metadata handler for {path_}")
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"failed to open {path_}: {e}")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def new(path_: str) -> 'AudioFile':
|
def new(path_: str) -> 'AudioFile':
|
||||||
|
Reference in New Issue
Block a user