Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle ValueError: year 0 is out of range #40

Open
jsetton opened this issue Jul 10, 2020 · 1 comment
Open

Handle ValueError: year 0 is out of range #40

jsetton opened this issue Jul 10, 2020 · 1 comment

Comments

@jsetton
Copy link

jsetton commented Jul 10, 2020

audio-metadata version

Name: audio-metadata
Version: 0.11.1
Summary: A library for reading and, in the future, writing metadata from audio files.
Home-page: https://github.com/thebigmunch/audio-metadata
Author: thebigmunch
Author-email: [email protected]
License: MIT
Location: /usr/lib/python3.8/site-packages
Requires: bidict, pendulum, tbm-utils, wrapt, attrs, more-itertools, pprintpp, bitstruct
Required-by: google-music, google-music-utils, google-music-scripts, google-music-proto

Python version

Python 3.8.2

Exception traceback

Traceback (most recent call last):
  File "/usr/bin/gms", line 8, in <module>
    sys.exit(run())
  File "/usr/lib/python3.8/site-packages/google_music_scripts/cli.py", line 618, in run
    args.func(args)
  File "/usr/lib/python3.8/site-packages/google_music_scripts/commands.py", line 390, in do_upload
    local_songs = get_local_songs(
  File "/usr/lib/python3.8/site-packages/google_music_scripts/core.py", line 186, in get_local_songs
    local_songs = [
  File "/usr/lib/python3.8/site-packages/google_music_scripts/core.py", line 195, in <listcomp>
    if audio_metadata.determine_format(filepath) in [
  File "/usr/lib/python3.8/site-packages/audio_metadata/api.py", line 72, in determine_format
    ID3v2.parse(data)
  File "/usr/lib/python3.8/site-packages/tbm_utils/decorators.py", line 44, in wrapper
    return wrapped(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/audio_metadata/formats/id3v2.py", line 416, in parse
    self.tags = ID3v2Frames.parse(
  File "/usr/lib/python3.8/site-packages/tbm_utils/decorators.py", line 44, in wrapper
    return wrapped(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/audio_metadata/formats/id3v2.py", line 246, in parse
    frame = ID3v2Frame.parse(data, id3_version, unsync)
  File "/usr/lib/python3.8/site-packages/tbm_utils/decorators.py", line 44, in wrapper
    return wrapped(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/audio_metadata/formats/id3v2frames.py", line 551, in parse
    return frame_type(
  File "<attrs generated init audio_metadata.formats.id3v2frames.ID3v2TimestampFrame>", line 6, in __init__
  File "/usr/lib/python3.8/site-packages/audio_metadata/formats/id3v2frames.py", line 1423, in _validate_value
    parse_iso8601(v)
  File "/usr/lib/python3.8/site-packages/pendulum/parsing/iso8601.py", line 187, in parse_iso8601
    return datetime.date(year, month, day)
ValueError: year 0 is out of range

Proposed fix

Similar to https://github.com/thebigmunch/google-music-proto/issues/6, ValueError should be gracefully handled.

--- audio_metadata/formats/id3v2frames.py.orig
+++ audio_metadata/formats/id3v2frames.py
@@ -1421,7 +1421,7 @@
                for v in value:
                        try:
                                parse_iso8601(v)
-                       except ParserError:
+                       except (ParserError, ValueError):
                                raise TagError("Timestamp frame values must conform to the ID3v2-compliant subset of ISO 8601.")

        @datareader
@thebigmunch
Copy link
Owner

Changed the label to enhancement, since it's not technically a bug to error out on invalid input. But audio-metadata should definitely handle this case gracefully as well as ParserError.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants