diff --git a/sdgb/chime.py b/sdgb/chime.py index e8e1e72..e5bd812 100644 --- a/sdgb/chime.py +++ b/sdgb/chime.py @@ -2,10 +2,11 @@ import hashlib import httpx import pytz import json +import asyncio from datetime import datetime from settings import KeychipID -def qr_api(qr_code: str): +async def QRApi(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") @@ -23,10 +24,11 @@ def qr_api(qr_code: str): "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 - ) + async with httpx.AsyncClient() as client: + res = await client.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) diff --git a/sdgb/ticket.py b/sdgb/ticket.py index b7e2e74..3f2472f 100644 --- a/sdgb/ticket.py +++ b/sdgb/ticket.py @@ -1,4 +1,3 @@ -import json import asyncio import httpx import time @@ -38,32 +37,9 @@ async def run_workflow(self): loginId = LoginResponse['loginId'] loginDate = LoginResponse['lastLoginDate'] - # UserData 等 + # User Charge - tasks = [ - self.call_api(client, "GetUserDataApi", requestData_UserData, userId), - self.call_api(client, "GetUserExtendApi", requestData_UserData, userId), - self.call_api(client, "GetUserOptionApi", requestData_UserData, userId), - self.call_api(client, "GetUserRatingApi", requestData_UserData, userId), - self.call_api(client, "GetUserChargeApi", requestData_UserData, userId), - self.call_api(client, "GetUserActivityApi", requestData_UserData, userId), - self.call_api(client, "GetUserMissionDataApi", requestData_UserData, userId), - ] - - GeneralUserInfo = await asyncio.gather(*tasks) - time.sleep(60) # 模拟游戏时间 - - # UserPlaylog - - requestData_UserPlaylog = UserPlaylog_payload(loginId, musicData, GeneralUserInfo[0]) - - await self.call_api(client, "UploadUserPlaylogListApi", requestData_UserPlaylog, userId) - - # Userall - - requestData_Userall = UserAll_payload(loginId, loginDate, musicData, GeneralUserInfo) - - await self.call_api(client, "UpsertUserAllApi", requestData_Userall, userId) + await self.call_api(client, "UpsertUserChargelogApi", requestData_UserChargelog, userId) # UserLogout