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

ZeroDivisionError when downloading via search results #24

Open
nwgreenl opened this issue Feb 11, 2022 · 0 comments
Open

ZeroDivisionError when downloading via search results #24

nwgreenl opened this issue Feb 11, 2022 · 0 comments

Comments

@nwgreenl
Copy link

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.

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

No branches or pull requests

1 participant