Huge Rewrite!

This commit is contained in:
Remik1r3n
2025-02-02 03:17:13 +08:00
parent 3638de178d
commit 90d8b74c45
28 changed files with 1038 additions and 420 deletions

View File

@@ -1,7 +1,7 @@
import json
from loguru import logger
from Static_Settings import *
from Config import *
from API_TitleServer import apiSDGB, calcSpecialNumber, WahlapServerBoomedError, Request500Error
from HelperGetUserThing import implGetUser_
from HelperUploadUserPlayLog import apiUploadUserPlaylog
@@ -39,10 +39,19 @@ def applyUserAllPatches(userAll, patches):
if isinstance(value, dict) and key in userAll and isinstance(userAll[key], dict):
# 如果patch的值是字典并且userAll中对应的key也是字典递归处理
applyUserAllPatches(userAll[key], value)
elif isinstance(value, list) and key in userAll and isinstance(userAll[key], list):
# 如果值是列表,进行详细的更新处理
for i, patch_item in enumerate(value):
if i < len(userAll[key]) and isinstance(patch_item, dict) and isinstance(userAll[key][i], dict):
# 如果列表项是字典,更新字典中的字段
applyUserAllPatches(userAll[key][i], patch_item)
elif i >= len(userAll[key]):
# 如果patch的列表比userAll的列表长追加新的元素
userAll[key].append(patch_item)
else:
# 否则直接更新或添加key
userAll[key] = value
def implFullPlayAction(userId: int, currentLoginTimestamp:int, currentLoginResult, musicData, userAllPatches, debugMode=False) -> str:
'''
一份完整的上机实现,可以打 patch 来实现各种功能
@@ -81,7 +90,8 @@ def implFullPlayAction(userId: int, currentLoginTimestamp:int, currentLoginResul
# 调试模式下直接输出数据
if debugMode:
logger.debug("调试模式:当前 UserAll 数据:" + json.dumps(currentUserAll, indent=4))
logger.debug("调试模式:构建出的 UserAll 数据:" + json.dumps(currentUserAll, indent=4))
logger.info("Bye!")
return
# 建构 Json 数据
@@ -90,7 +100,7 @@ def implFullPlayAction(userId: int, currentLoginTimestamp:int, currentLoginResul
try:
currentUserAllResult = json.loads(apiSDGB(data, "UpsertUserAllApi", userId))
except Request500Error:
logger.warning("500 Error Triggered. Rebuilding data.")
logger.warning("上传 UserAll 出现 500. 重建数据.")
retries += 1
continue
except Exception: