From 9dcf4f6fd37cae533fb76fc221893a981541e3c5 Mon Sep 17 00:00:00 2001 From: Rene Luria Date: Mon, 29 Jun 2026 16:30:35 +0200 Subject: [PATCH] chore: add some debug --- myice/myice.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/myice/myice.py b/myice/myice.py index 927de39..3e09f04 100755 --- a/myice/myice.py +++ b/myice/myice.py @@ -594,6 +594,18 @@ mobile_headers = { } +def curl_for_mobile_login(username: str, password: str) -> str: + """Generate curl command to replicate mobile_login request.""" + import base64 + + headers_str = " ".join([f"-H '{k}: {v}'" for k, v in mobile_headers.items()]) + encoded_username = base64.b64encode(username.encode()).decode() + encoded_password = base64.b64encode(password.encode()).decode() + return f"""curl -X POST "https://app.myice.hockey/api/mobilerest/login" \ +{headers_str} \ +-d 'login_email={encoded_username}&login_password={encoded_password}&language=FR&v=2'""" + + def mobile_login(config_section: str | None = None): global global_config_section import base64 @@ -606,6 +618,8 @@ def mobile_login(config_section: str | None = None): return {"id": 0, "token": token, "id_club": club_id} print("Requesting token", file=sys.stderr) + # Print curl equivalent for debugging + print(curl_for_mobile_login(username, password), file=sys.stderr) with requests.post( "https://app.myice.hockey/api/mobilerest/login", headers=mobile_headers, @@ -628,7 +642,19 @@ userdata = { } +def curl_for_refresh_data(token: str, club_id: int) -> str: + """Generate curl command to replicate refresh_data request.""" + headers_str = " ".join([f"-H '{k}: {v}'" for k, v in mobile_headers.items()]) + return f"""curl -X POST "https://app.myice.hockey/api/mobilerest/refreshdata" \ +{headers_str} \ +-d 'token={token}&id_club={club_id}&language=FR'""" + + def refresh_data(): + # Print curl equivalent for debugging + print( + curl_for_refresh_data(userdata["token"], userdata["id_club"]), file=sys.stderr + ) with requests.post( "https://app.myice.hockey/api/mobilerest/refreshdata", headers=mobile_headers,