From 9183c01779f7522043296f4f5aa1a2998b4b3c08 Mon Sep 17 00:00:00 2001 From: Ryszard Knop Date: Sun, 3 Oct 2021 13:33:40 +0200 Subject: [PATCH] Pass credentials for file downloads too This didn't actually pull private games - now it works. --- downloader.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/downloader.py b/downloader.py index ca5f337..6657b8b 100755 --- a/downloader.py +++ b/downloader.py @@ -75,10 +75,10 @@ class ItchApiClient(): return self.requests.get(self.base_url + endpoint, *args, **kwargs) -def download_file(client: ItchApiClient, upload_id: int, download_path: str, print_url: bool=False): +def download_file(client: ItchApiClient, upload_id: int, download_path: str, creds: dict, print_url: bool=False): # No timeouts, chunked uploads, default retry strategy, should be all good? try: - with client.get(f"/uploads/{upload_id}/download", stream=True) as r: + with client.get(f"/uploads/{upload_id}/download", data=creds, stream=True) as r: r.raise_for_status() if print_url: print(f"Download URL: {r.url}") @@ -235,7 +235,7 @@ def download_jam(path_to_json: str, download_to: str, api_key: str, continue_fro target_path = os.path.join(download_path, file_name) try: - download_file(client, upload_id, target_path, print_url=upload_is_external) + download_file(client, upload_id, target_path, creds, print_url=upload_is_external) except ItchDownloadError as e: jobs_failed.append((game_id, file_name, str(e))) print(f"Download failed for {file_name}: {e}")