Add files via upload

This commit is contained in:
Roy 2024-01-18 18:53:00 -08:00 committed by GitHub
parent c14c9c3b61
commit 25b67e2879
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -164,15 +164,14 @@ def download_artwork(game_id, api_key, art_type, shortcut_id, dimensions=None):
response = requests.get(image_url, stream=True) response = requests.get(image_url, stream=True)
response.raise_for_status() response.raise_for_status()
if response.status_code == 200: if response.status_code == 200:
os.makedirs(os.path.dirname(file_path), exist_ok=True)
with open(file_path, 'wb') as file: with open(file_path, 'wb') as file:
file.write(response.content) file.write(response.content)
break break
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
print(f"Error downloading image: {e}") # Added print statement print(f"Error downloading image: {e}")
if art_type == 'icons': if art_type == 'icons':
download_artwork(game_id, api_key, 'icons_ico', shortcut_id) download_artwork(game_id, api_key, 'icons_ico', shortcut_id)
if art_type in ['wide_grid', 'big_picture']:
download_artwork(game_id, api_key, 'hero', shortcut_id)
def get_game_id(game_name): def get_game_id(game_name):