mirror of
https://github.com/Emersont1/itchio.git
synced 2026-03-11 08:54:39 +00:00
pylint & black fixes
This commit is contained in:
parent
17d919d579
commit
6e2d739b35
3 changed files with 19 additions and 13 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue