feat: 每月定时开始学习并改为本地计算心跳摘要
This commit is contained in:
+6
-17
@@ -365,12 +365,12 @@ def jigsaw_offset(big_png: bytes, small_png: bytes, top: int) -> int:
|
||||
return best_x
|
||||
|
||||
|
||||
_SCORM_MD5_KEY = "60db8c0a-72d8-4b8f-bb45-c4c3f29a2696"
|
||||
STUDY_MD5_KEY = "60db8c0a-72d8-4b8f-bb45-c4c3f29a2696"
|
||||
|
||||
|
||||
def _scorm_md5(body_json: str) -> str:
|
||||
"""RteApiSite.js 里的本地 MD5:hex_md5(JSON + 固定 key)。"""
|
||||
return hashlib.md5((body_json + _SCORM_MD5_KEY).encode("utf-8")).hexdigest()
|
||||
def study_encryption(body_json: str) -> str:
|
||||
"""播放页 RteApiSite.js 的摘要:MD5(进度 JSON + 固定 key),与 GetEncryptRequest 相同。"""
|
||||
return hashlib.md5((body_json + STUDY_MD5_KEY).encode("utf-8")).hexdigest()
|
||||
|
||||
|
||||
class SessionExpired(RuntimeError):
|
||||
@@ -954,18 +954,7 @@ class EunivClient:
|
||||
return resp.json()
|
||||
|
||||
def get_encrypt_request(self, body_json: str) -> str:
|
||||
"""POST GetEncryptRequest,返回 32 位 MD5 摘要。"""
|
||||
resp = self.client.post(
|
||||
f"{EUNIV}/kng/services/KngComService.svc/GetEncryptRequest",
|
||||
json={"body": body_json},
|
||||
headers={"Content-Type": "text/json", "User-Agent": USER_AGENT},
|
||||
)
|
||||
data = resp.json()
|
||||
if isinstance(data, str):
|
||||
data = json.loads(data)
|
||||
if data.get("Status") == "OK":
|
||||
return str(data["Data"])
|
||||
raise RuntimeError(f"GetEncryptRequest 失败: {data}")
|
||||
return study_encryption(body_json)
|
||||
|
||||
def submit_video_heartbeat(self, knowledge_id: str, package_id: str,
|
||||
study_time: int, view_schedule: int,
|
||||
@@ -1050,7 +1039,7 @@ class EunivClient:
|
||||
"viewSchedule": 0,
|
||||
}
|
||||
if end:
|
||||
encryption = _scorm_md5(json.dumps(param, separators=(",", ":")))
|
||||
encryption = study_encryption(json.dumps(param, separators=(",", ":")))
|
||||
else:
|
||||
encrypt_body = json.dumps(param, separators=(",", ":"))
|
||||
encryption = self.get_encrypt_request(encrypt_body)
|
||||
|
||||
Reference in New Issue
Block a user