refactor(fudai): 抽 _handle_in_fudai_detail 中"提取 future_ts"和"detail 为 None 早返回"两块

- extract_future_ts_from_detail:从 detail tuple 提取倒计时 future_ts 写入 _current_fudai_future_ts
- handle_detail_none_in_step4:步骤4 detail 为 None 时的早返回处理

douyin_fudai.py: 1355 → 1341 行 (-14)
fudai_detail_helpers.py: 2742 → 2776 行

验证:
- pytest 1013 passed
- compile OK

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
CodexandClaude Opus 4.7 committed 2026-05-22 12:37:30 +08:00
1 parent 2ba2168665
commit 81b82e6cba
2 files changed
+43 -23

No files matched your search

+9 -23
View File
@@ -1258,16 +1258,11 @@ class fudai_analyse:
attend_before_ts = getattr(self, "_last_successful_attend_ts", 0.0) or 0.0
# 记录当前福袋的 future_ts,供 attend_choujiang 使用
try:
if isinstance(detail, tuple) and len(detail) >= 6:
d_cast: Tuple[Any, ...] = cast(Tuple[Any, ...], detail)
countdown_tuple = d_cast[5]
if isinstance(countdown_tuple, (tuple, list)) and len(countdown_tuple) >= 2:
future_ts = float(countdown_tuple[1] or 0.0)
if future_ts > 0:
self._current_fudai_future_ts = future_ts
except Exception:
pass
from douyin.core.fudai_modules.fudai_detail_helpers import (
extract_future_ts_from_detail,
)
extract_future_ts_from_detail(self, detail)
# 重置详情关闭标志
try:
@@ -1283,20 +1278,11 @@ class fudai_analyse:
step4_start = time.time()
# 执行参与决策
if detail is None:
try:
self._log_kv("参与", "详情数据为 None,无法执行参与决策")
except Exception:
pass
# 清除任务数量标志
clear_task_count_flag(self)
elapsed = time.time() - start_time
self._log_kv(
"流程",
"_handle_in_fudai_detail完成(详情为None)",
elapsed_seconds=round(elapsed, 2),
from douyin.core.fudai_modules.fudai_detail_helpers import (
handle_detail_none_in_step4,
)
handle_detail_none_in_step4(self, start_time)
return
join_result = douyin_fudai_core.basic_join_decision(
self, detail, (skip, skip_reason)
@@ -42,6 +42,40 @@ def log_screenshot_failed(
pass
def extract_future_ts_from_detail(analyser, detail) -> None:
"""从 detail tuple 中提取倒计时 future_ts 并写入 _current_fudai_future_ts。"""
try:
countdown_tuple = None
if isinstance(detail, tuple) and len(detail) >= 6:
countdown_tuple = detail[5]
if (
isinstance(countdown_tuple, (tuple, list))
and len(countdown_tuple) >= 2
):
future_ts = float(countdown_tuple[1] or 0.0)
if future_ts > 0:
analyser._current_fudai_future_ts = future_ts
except Exception:
pass
def handle_detail_none_in_step4(analyser, start_time: float) -> None:
"""步骤 4:detail 为 None 时的早返回处理(写日志 + clear_task_count_flag)。"""
try:
analyser._log_kv("参与", "详情数据为 None,无法执行参与决策")
except Exception:
pass
clear_task_count_flag(analyser)
elapsed = time.time() - start_time
analyser._log_kv(
"流程",
"_handle_in_fudai_detail完成(详情为None)",
elapsed_seconds=round(elapsed, 2),
)
def try_skip_to_in_fudai_detail_when_verified(analyser, start_time: float) -> bool:
"""_handle_live_room_has_or_not_fudai 入口:如果已验证过详情页,直接处理详情。