Init: v1 release
This commit is contained in:
73
sdgb/ticket.py
Normal file
73
sdgb/ticket.py
Normal file
@@ -0,0 +1,73 @@
|
||||
import json
|
||||
import asyncio
|
||||
import httpx
|
||||
import time
|
||||
import logging
|
||||
from sdgb import MaimaiClient
|
||||
|
||||
from settings import userId, musicData
|
||||
from payload import *
|
||||
|
||||
maimai = MaimaiClient()
|
||||
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
async def run_workflow(self):
|
||||
|
||||
async with httpx.AsyncClient(verify=False) as client:
|
||||
|
||||
# Preview 探测
|
||||
|
||||
PreviewResponse = json.loads(await self.call_api(client, "GetUserPreviewApi", requestData_UserPreview, userId))
|
||||
if PreviewResponse["isLogin"] == True:
|
||||
logger.error("已在他处登录。")
|
||||
return
|
||||
|
||||
# UserLogin
|
||||
|
||||
LoginResponse = json.loads(await self.call_api(client, "UserLoginApi", requestData_UserLogin, userId))
|
||||
if LoginResponse["returnCode"] == 106:
|
||||
logger.error("chime verfication failed.")
|
||||
return
|
||||
|
||||
loginId = LoginResponse['loginId']
|
||||
loginDate = LoginResponse['lastLoginDate']
|
||||
|
||||
# UserData 等
|
||||
|
||||
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)
|
||||
|
||||
# UserLogout
|
||||
|
||||
await self.call_api(client, "UserLogoutApi", requestData_UserLogout, userId)
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(run_workflow(maimai))
|
||||
Reference in New Issue
Block a user