rembo10/headphones — Issue #471: Zero Division Error While Calculating Bitrate During Library Scan
Author: otoolejp
Created: 2012-02-08 19:05:40+00:00
State: open

While attempting to scan music library, a zero division error is thrown and scanning quits. I checked my library for suspect files that might be reporting damaged length, but didn't find any. It seems that this error is left unhandled. Sorry, I didn't keep the full traceback.
It comes from the end of mediafile.py in the bitrate method (or whatever Python calls them.) I duct-taped mine to simply return a 1 if a Zero Division Error is thrown. This allowed the library to complete the scan.

@property
def bitrate(self):
if hasattr(self.mgfile.info, 'bitrate'):
# Many formats provide it explicitly.
return self.mgfile.info.bitrate
else:
# Otherwise, we calculate bitrate from the file size. (This
# is the case for all of the lossless formats.)
size = os.path.getsize(self.path)
try:
return int(size * 8 / self.length)
except ZeroDivisionError:
return int(1)
else:
return int(size * 8 / self.length)