mower-ng/森空岛获取基本信息.py

49 lines
1.4 KiB
Python

import json
import requests
from mower.utils import config
from mower.utils.path import get_path
from mower.utils.skland import (
get_binding_list,
get_cred_by_token,
get_sign_header,
header,
log,
)
class cultivate:
solver_name = "森空岛数据获取"
def __init__(self):
self.record_path = get_path("@app/tmp/cultivate.json")
self.reward = []
self.sign_token = ""
self.all_recorded = True
def start(self):
item = config.conf.skland_info[0]
if item.isCheck:
a = get_cred_by_token(log(item))
self.save_param(a)
print(a)
for i in get_binding_list(self.sign_token):
body = {"gameId": 1, "uid": i.get("uid")}
ingame = f"https://zonai.skland.com/api/v1/game/player/info?uid={i.get('uid')}"
resp = requests.get(
ingame,
headers=get_sign_header(ingame, "get", body, self.sign_token),
timeout=5,
).json()
print(resp)
with open(self.record_path, "w", encoding="utf-8") as file:
json.dump(resp, file, ensure_ascii=False, indent=4)
def save_param(self, cred_resp):
header["cred"] = cred_resp["cred"]
self.sign_token = cred_resp["token"]
a = cultivate()
a.start()