From 33acac66095f15711d7e3c1e12f42a0136325adb Mon Sep 17 00:00:00 2001 From: Peter Taylor Date: Mon, 9 May 2022 17:05:03 +0100 Subject: [PATCH 1/2] Added Progress Output (#52) * Added Progress Option * VSCode adding unwanted imports * linting * Forgot to increment the Download total * fixed issues with counter * Added Mutex for safety * reorder imports --- itchiodl/library.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/itchiodl/library.py b/itchiodl/library.py index a401025..6503c37 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 itchiodl.game import Game @@ -38,9 +40,17 @@ class Library: def download_library(self, platform=None): """Download all games in the library""" + with ThreadPoolExecutor(max_workers=self.jobs) as executor: + i = [0] + l = len(self.games) + lock = threading.RLock() - def dl(g): - return g.download(self.login, platform) + def dl(i, g): + x = g.download(self.login, platform) + 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) From 64673b7ed26a85ed785647ee0454678d9e3278a9 Mon Sep 17 00:00:00 2001 From: Peter Taylor Date: Mon, 9 May 2022 17:21:22 +0100 Subject: [PATCH 2/2] Version bump --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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"