From 19cfda12e70e716d084502b82ef2bb1d0c0c3634 Mon Sep 17 00:00:00 2001 From: Peter Taylor Date: Mon, 20 Dec 2021 00:09:53 +0000 Subject: [PATCH] better resumes without as many web requests --- pyproject.toml | 2 +- src/itchio/game.py | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a461621..02c8ddc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "itchio" -version = "1.0.3" +version = "1.0.4" description = "Python Scripts for downloading / archiving your itchio library" authors = ["Peter Taylor "] license = "MIT" diff --git a/src/itchio/game.py b/src/itchio/game.py index b636649..012c8f2 100644 --- a/src/itchio/game.py +++ b/src/itchio/game.py @@ -29,6 +29,9 @@ class Game: self.downloads.append(d) def download(self, token): + if os.path.exists(f"{self.publisher_slug}/{self.game_slug}.json"): + print(f"Skipping Game {self.name}") + self.load_downloads(token) if not os.path.exists(self.publisher_slug): @@ -37,16 +40,6 @@ class Game: if not os.path.exists(f"{self.publisher_slug}/{self.game_slug}"): os.mkdir(f"{self.publisher_slug}/{self.game_slug}") - with open(f"{self.publisher_slug}/{self.game_slug}.json", "w") as f: - json.dump({ - "name": self.name, - "publisher": self.publisher, - "link": self.link, - "itch_id": self.id, - "game_id": self.game_id, - "itch_data": self.data, - }, f) - for d in self.downloads: file = d['filename'] or d['display_name'] or d['id'] outfile = f"{self.publisher_slug}/{self.game_slug}/{file}" @@ -62,3 +55,13 @@ class Game: url = f"https://api.itch.io/uploads/{d['id']}/download?api_key={token}&download_key_id={self.id}&uuid={j['uuid']}" itchio.utils.download_url(url, outfile, self.name +" - "+file) + + with open(f"{self.publisher_slug}/{self.game_slug}.json", "w") as f: + json.dump({ + "name": self.name, + "publisher": self.publisher, + "link": self.link, + "itch_id": self.id, + "game_id": self.game_id, + "itch_data": self.data, + }, f)