forked from Fragrance/eaquira
43 lines
1.0 KiB
Python
43 lines
1.0 KiB
Python
import hashlib
|
|
import json
|
|
from datetime import datetime
|
|
|
|
import httpx
|
|
import pytz
|
|
|
|
from sdgb.settings import KeychipID
|
|
|
|
|
|
def qr_api(qr_code: str):
|
|
if len(qr_code) > 64:
|
|
qr_code = qr_code[-64:]
|
|
time_stamp = datetime.now(pytz.timezone("Asia/Tokyo")).strftime("%y%m%d%H%M%S")
|
|
auth_key = (
|
|
hashlib.sha256(
|
|
(KeychipID + time_stamp + "XcW5FW4cPArBXEk4vzKz3CIrMuA5EVVW").encode(
|
|
"UTF-8"
|
|
)
|
|
)
|
|
.hexdigest()
|
|
.upper()
|
|
)
|
|
param = {
|
|
"chipID": KeychipID,
|
|
"openGameID": "MAID",
|
|
"key": auth_key,
|
|
"qrCode": qr_code,
|
|
"timestamp": time_stamp,
|
|
}
|
|
headers = {
|
|
"Contention": "Keep-Alive",
|
|
"Host": "ai.sys-all.cn",
|
|
"User-Agent": "WC_AIME_LIB",
|
|
}
|
|
res = httpx.post(
|
|
"http://ai.sys-allnet.cn/wc_aime/api/get_data",
|
|
data=json.dumps(param, separators=(",", ":")),
|
|
headers=headers,
|
|
)
|
|
assert res.status_code == 200, "网络错误"
|
|
return json.loads(res.content)
|