use same tracknum parser for flac as mp3
Gitea/pysonic/pipeline/head This commit looks good
Details
Gitea/pysonic/pipeline/head This commit looks good
Details
This commit is contained in:
parent
af0cfe029d
commit
51551f2b27
|
@ -291,6 +291,7 @@ class PysonicFilesystemScanner(object):
|
||||||
Scan the file for metadata.
|
Scan the file for metadata.
|
||||||
:param fpath: path to the file to scan
|
:param fpath: path to the file to scan
|
||||||
"""
|
"""
|
||||||
|
logging.info("getting metadata from %s", fpath)
|
||||||
ftype, extra = mimetypes.guess_type(fpath)
|
ftype, extra = mimetypes.guess_type(fpath)
|
||||||
|
|
||||||
if ftype in MUSIC_TYPES:
|
if ftype in MUSIC_TYPES:
|
||||||
|
@ -326,8 +327,6 @@ class PysonicFilesystemScanner(object):
|
||||||
except (ValueError, AttributeError):
|
except (ValueError, AttributeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
logging.info("scanning %s", fpath)
|
|
||||||
|
|
||||||
# these fields are format-specific
|
# these fields are format-specific
|
||||||
#TODO determine if having WAV_TYPES does anything at all
|
#TODO determine if having WAV_TYPES does anything at all
|
||||||
if ftype in MPX_TYPES or ftype in WAV_TYPES:
|
if ftype in MPX_TYPES or ftype in WAV_TYPES:
|
||||||
|
@ -349,7 +348,7 @@ class PysonicFilesystemScanner(object):
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
meta["year"] = int(audio['TDRC'].text[0].year)
|
meta["year"] = int(audio['TDRC'].text[0].year)
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError, ValueError):
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
meta["genre"] = audio['TCON'].text[0].strip()
|
meta["genre"] = audio['TCON'].text[0].strip()
|
||||||
|
@ -358,7 +357,7 @@ class PysonicFilesystemScanner(object):
|
||||||
|
|
||||||
elif ftype in FLAC_TYPES:
|
elif ftype in FLAC_TYPES:
|
||||||
try:
|
try:
|
||||||
meta["track"] = int(audio["tracknumber"][0])
|
meta["track"] = int(RE_NUMBERS.findall(audio["tracknumber"][0])[0])
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
|
@ -375,13 +374,11 @@ class PysonicFilesystemScanner(object):
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
meta["year"] = int(audio["date"][0]) # TODO is this ever a full date?
|
meta["year"] = int(audio["date"][0]) # TODO is this ever a full date?
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError, ValueError):
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
meta["genre"] = audio["genre"][0].strip()
|
meta["genre"] = audio["genre"][0].strip()
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
logging.info("got all media info from %s", fpath)
|
|
||||||
|
|
||||||
return meta
|
return meta
|
||||||
|
|
Loading…
Reference in New Issue