From 9a370b26bc625f3e95838b6609ce529b9cfb5a3e Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Tue, 8 Mar 2022 13:19:04 +0100 Subject: [PATCH] Fix utils.download function call (#8) --- src/itchio/game.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/itchio/game.py b/src/itchio/game.py index 14a7c8b..d4f13d7 100644 --- a/src/itchio/game.py +++ b/src/itchio/game.py @@ -46,9 +46,9 @@ class Game: for d in self.downloads: file = d['filename'] or d['display_name'] or d['id'] - outfile = f"{self.publisher_slug}/{self.game_slug}/{file}" - if os.path.exists(outfile): - print(f"Skipping {outfile}") + path = f"{self.publisher_slug}/{self.game_slug}" + if os.path.exists(f"{path}/{file}"): + print(f"Skipping {path}/{file}") continue # Get UUID @@ -59,14 +59,15 @@ class Game: url = f"https://api.itch.io/uploads/{d['id']}/download?api_key={token}&download_key_id={self.id}&uuid={j['uuid']}" # response_code = urllib.request.urlopen(url).getcode() try: - itchio.utils.download_url(url, outfile, self.name +" - "+file) + itchio.utils.download(url, path, self.name +" - "+file) except urllib.error.HTTPError as e: print("This one has broken!!") with open('errors.txt', 'a') as f: f.write(f""" Cannot download game/asset: {self.game_slug} Publisher Name: {self.publisher_slug} - Output File: {outfile} + Path: {path} + File: {file} Request URL: {url} Request Response Code: {e.code} Error Reason: {e.reason}