From 1d266d7e356f8ee27eece0d8683dc46b89679697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sun, 25 Jun 2023 10:07:11 +0200 Subject: [PATCH] download data: log failed game_json --- download_data.py | 2 +- site_api.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/download_data.py b/download_data.py index e57c9c8..69452c5 100644 --- a/download_data.py +++ b/download_data.py @@ -31,7 +31,7 @@ def detailed_export_game(game_id: int, score: Optional[int] = None, var_id: Opti assert_msg = "Invalid response format from hanab.live while exporting game id {}".format(game_id) game_json = get("export/{}".format(game_id)) - assert game_json.get('id') == game_id, assert_msg + assert game_json.get('id') == game_id, assert_msg + ": " + str(game_json) players = game_json.get('players', []) num_players = len(players) diff --git a/site_api.py b/site_api.py index c4c745f..c3f78fa 100644 --- a/site_api.py +++ b/site_api.py @@ -1,5 +1,5 @@ import json -import requests +from typing import Optional, Dict import requests_cache from log_setup import logger @@ -8,7 +8,7 @@ from log_setup import logger session = requests_cache.CachedSession('hanab.live') -def get(url, refresh=False): +def get(url, refresh=False) -> Optional[Dict]: # print("sending request for " + url) query = "https://hanab.live/" + url logger.debug("GET {} (force_refresh={})".format(query, refresh))