Compare commits
58 Commits
19e3f751ec
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
e77c034082
|
|||
|
0615dc6421
|
|||
|
71bbb67cef
|
|||
| a17c362c81 | |||
| 77b2531106 | |||
| 0d39efd034 | |||
| 12aada4986 | |||
| 9795a4c813 | |||
| 46ae216e97 | |||
| 19724b1f8b | |||
| 9e5db51972 | |||
| c0bfa85688 | |||
| ffe0a1cf18 | |||
| ff69806803 | |||
| 524c4db889 | |||
| 6b2965c18a | |||
| 9363a1f7ef | |||
| 449f5450fe | |||
| f302357545 | |||
| b1a792502f | |||
| 38e3564524 | |||
| 6a240c5773 | |||
| b04e8e2900 | |||
| f33bb46d73 | |||
| cd32efb657 | |||
| 747e9db582 | |||
| 768ac8375b | |||
| 4a5b2a5991 | |||
| c099f1328b | |||
| fe8a4e5d09 | |||
| 781d7000cd | |||
| 6903dab06b | |||
| abfad23a7a | |||
| 68ecce7d3a | |||
| 1941a924e2 | |||
| 702c425476 | |||
| a74da811c1 | |||
| dac110cee0 | |||
| 0fd58848f2 | |||
| de222023a8 | |||
| 08aa3f6a0e | |||
| 0e02245f21 | |||
| a86cf76228 | |||
| 3ab3273fba | |||
| a17467c313 | |||
| 9c6df3f6a2 | |||
| a17065b280 | |||
| 5f12fb08b8 | |||
| a2e44b6f50 | |||
| 15c148e233 | |||
| 7b6bf91502 | |||
| c5863ebc5f | |||
| 6c5668d608 | |||
| 0c62fcaa01 | |||
| bec33d0545 | |||
| c602727f08 | |||
| 6be182a894 | |||
| fafefd3085 |
@@ -169,3 +169,4 @@ cython_debug/
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
strix_runs/*
|
||||
|
||||
+24
-21
@@ -594,16 +594,16 @@ mobile_headers = {
|
||||
}
|
||||
|
||||
|
||||
def curl_for_mobile_login(username: str, password: str) -> str:
|
||||
"""Generate curl command to replicate mobile_login request."""
|
||||
import base64
|
||||
# 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'"""
|
||||
# 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):
|
||||
@@ -619,7 +619,7 @@ def mobile_login(config_section: str | None = None):
|
||||
|
||||
print("Requesting token", file=sys.stderr)
|
||||
# Print curl equivalent for debugging
|
||||
print(curl_for_mobile_login(username, password), file=sys.stderr)
|
||||
# print(curl_for_mobile_login(username, password), file=sys.stderr)
|
||||
with requests.post(
|
||||
"https://app.myice.hockey/api/mobilerest/login",
|
||||
headers=mobile_headers,
|
||||
@@ -643,23 +643,26 @@ 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 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():
|
||||
def refresh_data(user_data=None):
|
||||
# Use provided user_data or fall back to global userdata for backward compatibility
|
||||
if user_data is None:
|
||||
user_data = userdata
|
||||
# Print curl equivalent for debugging
|
||||
print(
|
||||
curl_for_refresh_data(userdata["token"], userdata["id_club"]), file=sys.stderr
|
||||
)
|
||||
# print(
|
||||
# curl_for_refresh_data(user_data["token"], user_data["id_club"]), file=sys.stderr
|
||||
# )
|
||||
with requests.post(
|
||||
"https://app.myice.hockey/api/mobilerest/refreshdata",
|
||||
headers=mobile_headers,
|
||||
data=f"token={userdata['token']}&id_club={userdata['id_club']}&language=FR",
|
||||
data=f"token={user_data['token']}&id_club={user_data['id_club']}&language=FR",
|
||||
# verify=False,
|
||||
) as r:
|
||||
r.raise_for_status()
|
||||
|
||||
+8
-8
@@ -352,15 +352,15 @@ async def schedule(
|
||||
|
||||
try:
|
||||
if existing_token:
|
||||
myice.userdata = {
|
||||
user_data = {
|
||||
"id": userid,
|
||||
"id_club": club_id or 186,
|
||||
"token": existing_token,
|
||||
}
|
||||
else:
|
||||
myice.userdata = myice.mobile_login(config_section=account)
|
||||
user_data = myice.mobile_login(config_section=account)
|
||||
|
||||
data = myice.refresh_data()
|
||||
data = myice.refresh_data(user_data=user_data)
|
||||
if "club_games" in data:
|
||||
return data["club_games"]
|
||||
else:
|
||||
@@ -433,13 +433,13 @@ async def game(
|
||||
config_section=account
|
||||
)
|
||||
if existing_token:
|
||||
myice.userdata = {
|
||||
user_data = {
|
||||
"id": userid,
|
||||
"id_club": club_id or 186,
|
||||
"token": existing_token,
|
||||
}
|
||||
else:
|
||||
myice.userdata = myice.mobile_login(config_section=account)
|
||||
user_data = myice.mobile_login(config_section=account)
|
||||
|
||||
# data = refresh_data()
|
||||
with requests.post(
|
||||
@@ -447,11 +447,11 @@ async def game(
|
||||
headers=myice.mobile_headers,
|
||||
data="&".join(
|
||||
[
|
||||
f"token={myice.userdata['token']}",
|
||||
f"token={user_data['token']}",
|
||||
f"id_event={game_id}",
|
||||
"type=games",
|
||||
f"id_player={myice.userdata['id']}",
|
||||
f"id_club={myice.userdata['id_club']}",
|
||||
f"id_player={user_data['id']}",
|
||||
f"id_club={user_data['id_club']}",
|
||||
"language=FR",
|
||||
]
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user