From 82629660d24235ab9ff20ca3b9a99a787ffd8bec Mon Sep 17 00:00:00 2001 From: Peter Taylor Date: Sun, 29 Jan 2023 17:56:45 +0000 Subject: [PATCH] Fix None Download --- itchiodl/library.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/itchiodl/library.py b/itchiodl/library.py index 4c6bc44..0aee2f4 100644 --- a/itchiodl/library.py +++ b/itchiodl/library.py @@ -48,11 +48,27 @@ class Library: j = json.loads(rsp.text) game_id = j["id"] gsp = requests.get( - f"https://api.itch.io/games/{game_id}", + f"https://api.itch.io/games/{game_id}/uploads", headers={"Authorization": self.login}, ) - k = json.loads(gsp.text) - self.games.append(Game(k)) + k = gsp.json() + if k != {"uploads": {}}: + self.games.append(Game(k)) + return + print(f"{title} is a purchased game.") + i = 1 + while self.games == []: + self.games = [ + x + for x in self.games + if x.link == f"https://{publisher}.itch.io/{title}" + ] + if self.load_game_page(i) == 0: + break + i += 1 + + if self.games == []: + print(f"Cannot find {title} in owned keys, you may not own it.") def load_games(self, publisher): """Load all games by publisher"""