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

Duration handling for broken flac files #287

Closed
gfarmerfr opened this issue Jan 15, 2017 · 2 comments
Closed

Duration handling for broken flac files #287

gfarmerfr opened this issue Jan 15, 2017 · 2 comments
Labels
bug

Comments

@gfarmerfr
Copy link

@gfarmerfr gfarmerfr commented Jan 15, 2017

Hi,

I stumble upon some broken flac files in the wild that doesn't report a correct length (duration).

Prior to 1.36 they were reporting a duration of 0.0:

>>> import mutagen
>>> audio = mutagen.File("test.flac")
>>> audio.info.length
0.0

With 1.36 it's actually raising a ZeroDivisionError:

>>> import mutagen
>>> audio = mutagen.File("test.flac")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "venv/lib/python2.7/site-packages/mutagen/_util.py", line 131, in wrapper_func
    return func(h, *args, **kwargs)
  File "venv/lib/python2.7/site-packages/mutagen/_file.py", line 295, in File
    return Kind(fileobj, filename=filething.filename)
  File "venv/lib/python2.7/site-packages/mutagen/_file.py", line 48, in __init__
    self.load(*args, **kwargs)
  File "venv/lib/python2.7/site-packages/mutagen/_util.py", line 152, in wrapper
    return func(*args, **kwargs)
  File "venv/lib/python2.7/site-packages/mutagen/_util.py", line 123, in wrapper
    return func(self, h, *args, **kwargs)
  File "venv/lib/python2.7/site-packages/mutagen/flac.py", line 801, in load
    float(fileobj.tell() - start) * 8 / self.info.length)
ZeroDivisionError: float division by zero

I think this was introduced by adding the bitrate info in this commit: d8aed5a

If you decide to handle this type of broken files should the bitrate be 0 ?

@lazka lazka added the bug label Jan 16, 2017
@lazka lazka closed this in 5aab4c1 Jan 16, 2017
@lazka

This comment has been minimized.

Copy link
Member

@lazka lazka commented Jan 16, 2017

Thanks

@gfarmerfr

This comment has been minimized.

Copy link
Author

@gfarmerfr gfarmerfr commented Jan 16, 2017

No problem, thx for the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.