mirror of
https://github.com/Emersont1/itchio.git
synced 2026-03-11 08:54:39 +00:00
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
This commit is contained in:
parent
da2d93a10b
commit
33acac6609
1 changed files with 13 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue