diff --git a/itchiodl/__init__.py b/itchiodl/__init__.py index e2e7914..c80181a 100644 --- a/itchiodl/__init__.py +++ b/itchiodl/__init__.py @@ -1,3 +1,5 @@ +# pylint: disable=consider-using-from-import +import itchiodl.utils as utils from .login import LoginWeb, LoginAPI from .bundle import Bundle from .library import Library diff --git a/itchiodl/game.py b/itchiodl/game.py index b26a42a..3937c49 100644 --- a/itchiodl/game.py +++ b/itchiodl/game.py @@ -2,10 +2,10 @@ import re import json import urllib import datetime -import requests from pathlib import Path +import requests -import itchiodl.utils as utils +from itchiodl import utils class Game: @@ -29,6 +29,11 @@ class Game: self.files = [] self.downloads = [] + self.dir = ( + Path(".") + / utils.clean_path(self.publisher_slug) + / utils.clean_path(self.game_slug) + ) def load_downloads(self, token): """Load all downloads for this game""" @@ -57,12 +62,7 @@ class Game: self.load_downloads(token) - self.dir = ( - Path(".") - / utils.clean_path(self.publisher_slug) - / utils.clean_path(self.game_slug) - ) - self.dir.mkdir(parents= True, exist_ok=True) + self.dir.mkdir(parents=True, exist_ok=True) for d in self.downloads: if ( diff --git a/itchiodl/library.py b/itchiodl/library.py index d6eba1a..1132735 100644 --- a/itchiodl/library.py +++ b/itchiodl/library.py @@ -6,6 +6,7 @@ import requests from bs4 import BeautifulSoup from itchiodl.game import Game +from itchiodl.utils import NoDownloadError class Library: @@ -89,18 +90,21 @@ 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, 0] l = len(self.games) lock = threading.RLock() def dl(i, g): try: - x = g.download(self.login, platform) + g.download(self.login, platform) with lock: i[0] += 1 print(f"Downloaded {g.name} ({i[0]} of {l})") - return x - except Exception as e: + except NoDownloadError as e: print(e) + i[1] += 1 - executor.map(functools.partial(dl, i), self.games) + r = executor.map(functools.partial(dl, i), self.games) + for _ in r: + pass + print(f"Downloaded {i[0]} Games, {i[1]} Errors")