fix: 加速间隔只决定发送频率,心跳仍按平台的一段学时申报

This commit is contained in:
2026-11-17 11:50:59 +08:00
parent 2cb6623ac4
commit 85e52b972c
2 changed files with 22 additions and 9 deletions
+15 -8
View File
@@ -269,21 +269,28 @@ def _completed(payload: dict) -> bool:
return str(payload.get("status") or "").strip().lower() == "completed"
def _payload_time(wait: int, fallback: int) -> int:
if wait > 0:
return int(wait)
return max(1, int(fallback or 1))
def _declared_study_time(ctype: str, params: dict | None) -> int:
"""平台入账只认播放页上的一段时长。手动间隔只决定隔多久发一次,不改这一段报多少秒。"""
video = ctype == "video"
raw = (params or {}).get("submitProTimes" if video else "validtimeSpan")
try:
value = int(raw or 0)
except (TypeError, ValueError):
value = 0
if value <= 0:
value = 30 if video else 120
return value
def _interval_plan(ctype: str, intervals: dict, auto_mode: bool, params: dict) -> tuple[int, int, int]:
"""返回 (等待秒, 心跳 studyTime, pageSize)。等待 0 表示连续发送,studyTime 仍用播放页间隔。"""
"""返回 (等待秒, 心跳 studyTime, pageSize)。studyTime 始终是播放页的 30 或 120。"""
video = ctype == "video"
wait = int(intervals.get(ctype, 30 if video else 120) or 0)
fallback = int((params or {}).get("submitProTimes" if video else "validtimeSpan") or (30 if video else 120))
declared = _declared_study_time(ctype, params)
if auto_mode:
wait = max(1, fallback)
wait = max(1, declared)
page_size = max(1, int((params or {}).get("pageSize") or 1))
return wait, _payload_time(wait, fallback), page_size
return wait, declared, page_size
def _current_intervals() -> tuple[dict, bool]: