Initial commit: Add maimaiDX API web application with AimeDB scanning and logging features

This commit is contained in:
kejiz
2025-09-18 10:19:08 +08:00
commit 4e83f159f0
84 changed files with 14012 additions and 0 deletions

31
backend/GetAny.py Normal file
View File

@@ -0,0 +1,31 @@
# 获取用户简略预览数据的 API 实现,此 API 无需任何登录即可调取
from loguru import logger
import rapidjson as json
from API_TitleServer import apiSDGB
def apiGetAny(
userId,
apiName: str,
noLog: bool = False,
) -> str:
data = json.dumps({"userId": int(userId)})
preview_result = apiSDGB(data, apiName, userId, noLog)
return preview_result
# CLI 示例
if __name__ == "__main__":
userId = input("请输入用户 ID")
# userId = testUid8
# print(apiGetAny(userId, "GetUserRatingApi"))
# print(apiGetAny(userId, "GetUserPreviewApi"))
for type in ["course", "extend", "character", "activity", "charge", "option", "region"]:
try:
data = apiGetAny(userId, f"GetUser{type.title()}Api", noLog=True)
except Exception as e:
logger.error(f"failed when scraping {type}: {e}")
else:
print(f"{type}:", json.dumps(json.loads(data), ensure_ascii=False, indent=4))