forked from Fragrance/eaquira
refactor: split up modules
This commit is contained in:
42
src/sdgb/chime/__init__.py
Normal file
42
src/sdgb/chime/__init__.py
Normal file
@@ -0,0 +1,42 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user