fix: make 2024 api easier to use
This commit is contained in:
@@ -16,16 +16,18 @@ from Config import (
|
||||
proxyUrl,
|
||||
)
|
||||
|
||||
use2024Api = False # 是否使用 2024 API
|
||||
|
||||
if use2024Api:
|
||||
AesKey = "a>32bVP7v<63BVLkY[xM>daZ1s9MBP<R"
|
||||
AesIV = "d6xHIKq]1J]Dt^ue"
|
||||
ObfuscateParam = "B44df8yT"
|
||||
|
||||
|
||||
def use2024Api():
|
||||
global AesKey, AesIV, ObfuscateParam
|
||||
|
||||
AesKey = "n7bx6:@Fg_:2;5E89Phy7AyIcpxEQ:R@"
|
||||
AesIV = ";;KjR1C3hgB1ovXa"
|
||||
ObfuscateParam = "BEs2D5vW"
|
||||
else:
|
||||
AesKey = "a>32bVP7v<63BVLkY[xM>daZ1s9MBP<R"
|
||||
AesIV = "d6xHIKq]1J]Dt^ue"
|
||||
ObfuscateParam = "B44df8yT"
|
||||
|
||||
|
||||
class SDGBApiError(Exception):
|
||||
@@ -117,11 +119,15 @@ def apiSDGB(
|
||||
else:
|
||||
httpClient = httpx.Client(verify=False)
|
||||
|
||||
api_hash = getSDGBApiHash(targetApi)
|
||||
|
||||
logger.info(f"hash: {api_hash}")
|
||||
|
||||
# 发送请求
|
||||
response = httpClient.post(
|
||||
url=endpoint + getSDGBApiHash(targetApi),
|
||||
url=endpoint + api_hash,
|
||||
headers={
|
||||
"User-Agent": f"{getSDGBApiHash(targetApi)}#{agentExtra}",
|
||||
"User-Agent": f"{api_hash}#{agentExtra}",
|
||||
"Content-Type": "application/json",
|
||||
"Mai-Encoding": "1.50",
|
||||
"Accept-Encoding": "",
|
||||
@@ -144,8 +150,6 @@ def apiSDGB(
|
||||
# 处理响应内容
|
||||
responseContentRaw = response.content
|
||||
|
||||
print(list(responseContentRaw))
|
||||
|
||||
# 先尝试解密
|
||||
try:
|
||||
responseContentDecrypted = aes.decrypt(responseContentRaw)
|
||||
|
||||
@@ -7,7 +7,6 @@ from API_TitleServer import apiSDGB
|
||||
def apiGetUserPreview(userId, noLog: bool = False) -> str:
|
||||
data = json.dumps({"userId": int(userId)})
|
||||
preview_result = apiSDGB(data, "GetUserPreviewApi", userId, noLog)
|
||||
print(apiSDGB("{}", "Ping", userId, noLog))
|
||||
return preview_result
|
||||
|
||||
|
||||
@@ -16,3 +15,4 @@ if __name__ == "__main__":
|
||||
userId = input("请输入用户 ID:")
|
||||
# userId = testUid8
|
||||
print(apiGetUserPreview(userId))
|
||||
print(apiSDGB("{}", "Ping", userId, False))
|
||||
|
||||
21
GetPreview2024.py
Normal file
21
GetPreview2024.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# 获取用户简略预览数据的 API 实现,此 API 无需任何登录即可调取
|
||||
|
||||
import rapidjson as json
|
||||
|
||||
from API_TitleServer import apiSDGB_2024, use2024Api
|
||||
|
||||
use2024Api()
|
||||
|
||||
|
||||
def apiGetUserPreview(userId, noLog: bool = False) -> str:
|
||||
data = json.dumps({"userId": int(userId)})
|
||||
preview_result = apiSDGB_2024(data, "GetUserPreviewApi", userId, noLog)
|
||||
return preview_result
|
||||
|
||||
|
||||
# CLI 示例
|
||||
if __name__ == "__main__":
|
||||
userId = input("请输入用户 ID:")
|
||||
# userId = testUid8
|
||||
# print(apiGetUserPreview(userId))
|
||||
print(apiSDGB_2024("{}", "Ping", userId, False))
|
||||
Reference in New Issue
Block a user