diff --git a/pysonic/scanner.py b/pysonic/scanner.py index 5f680b2..4a95e66 100644 --- a/pysonic/scanner.py +++ b/pysonic/scanner.py @@ -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