xdcc-dl
xdcc-dl copied to clipboard
ZeroDivisionError when downloading via search results
Hey,
Just noticed this ZeroDivisionError
error below when testing out your package.
Exception in thread Thread-3 (progress_printer):
Traceback (most recent call last):
File "C:\Users\<me>\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
self.run()
File "C:\Users\<me>\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\<me>\AppData\Local\Programs\Python\Python310\lib\site-packages\xdcc_dl\xdcc\XDCCClient.py", line 626, in progress_printer
ratio = int(bytes_delta / time_delta)
ZeroDivisionError: float division by zero
Here's the test code I used, which produced the error
from xdcc_dl.xdcc import download_packs
from xdcc_dl.pack_search import SearchEngines
test_term = "[SubsPlease] Platinum End - 18 (1080p) [442FB8D7]"
search_results = SearchEngines.NIBL.value.search(test_term)
to_dl = [result for result in search_results if result.bot == "Ginpachi-Sensei"]
download_packs(to_dl)
The file still downloaded, but not progress bar was shown. I was able to fix the error locally by adding the following ternary to L626
ratio = int(bytes_delta / time_delta) if time_delta > 0 else 0
Would have submitted a PR but wasn't sure about your contribution guidelines. Sorry in advance if this was a known issue.