use same tracknum parser for flac as mp3
All checks were successful
Gitea/pysonic/pipeline/head This commit looks good

This commit is contained in:
dave 2022-06-02 16:00:43 -07:00
parent af0cfe029d
commit 51551f2b27

View File

@ -291,6 +291,7 @@ class PysonicFilesystemScanner(object):
Scan the file for metadata.
:param fpath: path to the file to scan
"""
logging.info("getting metadata from %s", fpath)
ftype, extra = mimetypes.guess_type(fpath)
if ftype in MUSIC_TYPES:
@ -326,8 +327,6 @@ class PysonicFilesystemScanner(object):
except (ValueError, AttributeError):
pass
logging.info("scanning %s", fpath)
# these fields are format-specific
#TODO determine if having WAV_TYPES does anything at all
if ftype in MPX_TYPES or ftype in WAV_TYPES:
@ -349,7 +348,7 @@ class PysonicFilesystemScanner(object):
pass
try:
meta["year"] = int(audio['TDRC'].text[0].year)
except (KeyError, IndexError):
except (KeyError, IndexError, ValueError):
pass
try:
meta["genre"] = audio['TCON'].text[0].strip()
@ -358,7 +357,7 @@ class PysonicFilesystemScanner(object):
elif ftype in FLAC_TYPES:
try:
meta["track"] = int(audio["tracknumber"][0])
meta["track"] = int(RE_NUMBERS.findall(audio["tracknumber"][0])[0])
except (KeyError, IndexError):
pass
try:
@ -375,13 +374,11 @@ class PysonicFilesystemScanner(object):
pass
try:
meta["year"] = int(audio["date"][0]) # TODO is this ever a full date?
except (KeyError, IndexError):
except (KeyError, IndexError, ValueError):
pass
try:
meta["genre"] = audio["genre"][0].strip()
except (KeyError, IndexError):
pass
logging.info("got all media info from %s", fpath)
return meta