whipper-team / whipper

Python CD-DA ripper preferring accuracy over speed
GNU General Public License v3.0
1.14k stars 90 forks source link

Handle "float division by zero" more gracefully #621

Open hadess opened 4 months ago

hadess commented 4 months ago

Trying to rip https://musicbrainz.org/release/9b7c8b00-0e37-4a0d-8fc1-3d0caa2c00c8 using one of my more reliable CD drives (a Samsung-branded USB DVD drive, TSSTcorp CDDVDW SE-208DB (MF00)), I got:

INFO:whipper.command.cd:using configured read offset 6
INFO:whipper.command.cd:checking device /dev/sr1
CDDB disc id: 02119e11
MusicBrainz disc id LGQXTzPqQ0PM04GzpYK553mQcP8-
MusicBrainz lookup URL https://musicbrainz.org/cdtoc/attach?toc=1+17+338429+150+19127+32902+43905+65508+81139+83375+109349+130786+147105+167660+198364+220295+248945+269620+296580+314878&tracks=17&id=LGQXTzPqQ0PM04GzpYK553mQcP8-
Disc duration: 01:15:10.386, 17 audio tracks

Matching releases:

Artist  : Bob Sinclar
Title   : Enjoy: The Movie & The Mix (Disc 1 of 2)
Duration: 01:15:10.379
URL     : https://musicbrainz.org/release/9b7c8b00-0e37-4a0d-8fc1-3d0caa2c00c8
Release : 9b7c8b00-0e37-4a0d-8fc1-3d0caa2c00c8
Type    : Compilation
Barcode : 826194003326
Country : United Kingdom
Cat no  : ENJOY01CD

INFO:whipper.command.cd:ripping track 1 of 17: 01. Bob Sinclar - Save our Soul.flac
WARNING:whipper.program.cdparanoia:file size 0 did not match expected size 44633948
WARNING:whipper.program.cdparanoia:non-integral amount of frames difference
Traceback (most recent call last): 100 %
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 193, in getTrackQuality
    return min(frames * 2.0 / reads, 1.0)
               ~~~~~~~~~~~~~^~~~~~~
ZeroDivisionError: float division by zero

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/whipper/extern/task/task.py", line 523, in c
    callable_task(*args, **kwargs)
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 324, in _read
    self._done()
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 400, in _done
    self.quality = self._parser.getTrackQuality()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 195, in getTrackQuality
    raise RuntimeError("cdparanoia couldn't read any frames "
RuntimeError: cdparanoia couldn't read any frames for the current track
INFO:whipper.command.cd:ripping track 1 of 17 (try 2): 01. Bob Sinclar - Save our Soul.flac
WARNING:whipper.program.cdparanoia:file size 0 did not match expected size 44633948
WARNING:whipper.program.cdparanoia:non-integral amount of frames difference
Traceback (most recent call last):f 9) ... 100 %
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 193, in getTrackQuality
    return min(frames * 2.0 / reads, 1.0)
               ~~~~~~~~~~~~~^~~~~~~
ZeroDivisionError: float division by zero

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/whipper/extern/task/task.py", line 523, in c
    callable_task(*args, **kwargs)
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 324, in _read
    self._done()
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 400, in _done
    self.quality = self._parser.getTrackQuality()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 195, in getTrackQuality
    raise RuntimeError("cdparanoia couldn't read any frames "
RuntimeError: cdparanoia couldn't read any frames for the current track
INFO:whipper.command.cd:ripping track 1 of 17 (try 3): 01. Bob Sinclar - Save our Soul.flac
WARNING:whipper.program.cdparanoia:file size 0 did not match expected size 44633948
WARNING:whipper.program.cdparanoia:non-integral amount of frames difference
Traceback (most recent call last):f 9) ... 100 %
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 193, in getTrackQuality
    return min(frames * 2.0 / reads, 1.0)
               ~~~~~~~~~~~~~^~~~~~~
ZeroDivisionError: float division by zero

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/whipper/extern/task/task.py", line 523, in c
    callable_task(*args, **kwargs)
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 324, in _read
    self._done()
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 400, in _done
    self.quality = self._parser.getTrackQuality()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 195, in getTrackQuality
    raise RuntimeError("cdparanoia couldn't read any frames "
RuntimeError: cdparanoia couldn't read any frames for the current track
INFO:whipper.command.cd:ripping track 1 of 17 (try 4): 01. Bob Sinclar - Save our Soul.flac
WARNING:whipper.program.cdparanoia:file size 0 did not match expected size 44633948
WARNING:whipper.program.cdparanoia:non-integral amount of frames difference
Traceback (most recent call last):f 9) ... 100 %
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 193, in getTrackQuality
    return min(frames * 2.0 / reads, 1.0)
               ~~~~~~~~~~~~~^~~~~~~
ZeroDivisionError: float division by zero

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/whipper/extern/task/task.py", line 523, in c
    callable_task(*args, **kwargs)
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 324, in _read
    self._done()
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 400, in _done
    self.quality = self._parser.getTrackQuality()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 195, in getTrackQuality
    raise RuntimeError("cdparanoia couldn't read any frames "
RuntimeError: cdparanoia couldn't read any frames for the current track
INFO:whipper.command.cd:ripping track 1 of 17 (try 5): 01. Bob Sinclar - Save our Soul.flac
WARNING:whipper.program.cdparanoia:file size 0 did not match expected size 44633948
WARNING:whipper.program.cdparanoia:non-integral amount of frames difference
Traceback (most recent call last):f 9) ... 100 %
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 193, in getTrackQuality
    return min(frames * 2.0 / reads, 1.0)
               ~~~~~~~~~~~~~^~~~~~~
ZeroDivisionError: float division by zero

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/whipper/extern/task/task.py", line 523, in c
    callable_task(*args, **kwargs)
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 324, in _read
    self._done()
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 400, in _done
    self.quality = self._parser.getTrackQuality()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/site-packages/whipper/program/cdparanoia.py", line 195, in getTrackQuality
    raise RuntimeError("cdparanoia couldn't read any frames "
RuntimeError: cdparanoia couldn't read any frames for the current track
CRITICAL:whipper.command.cd:giving up on track 1 after 5 times

The division by zero should probably be caught.

Using whipper-0.10.0-11.fc39.x86_64, issue is similar to https://github.com/whipper-team/whipper/issues/202

migrgh commented 4 months ago

fedora https://bugzilla.redhat.com/show_bug.cgi?id=2260787

MerlijnWajer commented 4 months ago

I don't think this issue is related to the issue above, I believe this can happen for example if cdparanoia cannot rip a track. I think the request is to show a more sensible error, but I am not quite sure what it should be.

hadess commented 4 months ago

I don't think this issue is related to the issue above,

It's not that libcdio bug, all the other discs can be ripped. This drive didn't like the disc, I tested it in another drive and it worked fine.

I believe this can happen for example if cdparanoia cannot rip a track. I think the request is to show a more sensible error, but I am not quite sure what it should be.

I think that the "cdparanoia couldn't read any frames for the current track" and "giving up..." messages are fine, we just need to get rid of the Python traceback.