diff --git a/itchiodl/library.py b/itchiodl/library.py index df0e8f0..4c6bc44 100644 --- a/itchiodl/library.py +++ b/itchiodl/library.py @@ -1,5 +1,7 @@ import json from concurrent.futures import ThreadPoolExecutor +import functools +import threading import requests from bs4 import BeautifulSoup @@ -67,14 +69,16 @@ class Library: def download_library(self, platform=None): """Download all games in the library""" - with ThreadPoolExecutor(max_workers=self.jobs) as executor: - i = 0 + i = [0] l = len(self.games) + lock = threading.RLock() - def dl(g): + def dl(i, g): x = g.download(self.login, platform) - print(f"Downloaded {i} games of {l}") + with lock: + i[0] += 1 + print(f"Downloaded {g.name} ({i[0]} of {l})") return x - executor.map(dl, self.games) + executor.map(functools.partial(dl, i), self.games) diff --git a/pyproject.toml b/pyproject.toml index 6cd6614..7b9fb74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "itchiodl" -version = "1.2.1" +version = "2.0.0" description = "Python Scripts for downloading / archiving your itchio library" authors = ["Peter Taylor "] license = "MIT" @@ -22,4 +22,4 @@ build-backend = "poetry.core.masonry.api" [tool.poetry.plugins."console_scripts"] "itch-download" = "itchiodl.downloader.__main__:main" -"itch-load-bundle" = "itchiodl.bundle_tool.__main__:main" \ No newline at end of file +"itch-load-bundle" = "itchiodl.bundle_tool.__main__:main"