refactor(fudai): 抽 run_once_basic 入口"记录直播间标题"块到 record_room_title_if_not_just_switched

将 run_once_basic 入口的"记录直播间标题"块(约 14 行)抽到 helper:
- 检查 _just_switched_room 标志
- 未刚切换时调用 _record_room_title_and_pos
- 刚切换时写"跳过重复记录"日志

douyin_fudai.py: 1412 → 1404 行 (-8)
fudai_detail_helpers.py: 2640 → 2659 行

验证:
- 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:30:36 +08:00
1 parent e3372fa51d
commit d9323f2012
2 files changed
+25 -14

No files matched your search

+6 -14
View File
@@ -692,20 +692,12 @@ class fudai_analyse:
except Exception:
pass
# 尝试记录当前直播间的标题与位置,确保所有直播间(不限福袋)都被采集到运行时映射表
# 但如果刚刚切换直播间,避免重复记录(切换前已记录)
try:
just_switched = getattr(self, "_just_switched_room", False)
if not just_switched:
self._record_room_title_and_pos()
else:
self._log_kv(
"预约",
"[预约] 刚刚切换直播间,跳过重复记录标题",
reason="avoid_duplicate_after_switch",
)
except Exception:
pass
# 尝试记录当前直播间的标题与位置(如果刚切换则跳过重复记录)
from douyin.core.fudai_modules.fudai_detail_helpers import (
record_room_title_if_not_just_switched,
)
record_room_title_if_not_just_switched(self)
# 直接参与标志已移除,相关旧逻辑已清理,继续按正常流程执行
# 0. 如果正在等待开奖:不在此期间检查并抢占其他预约,避免放弃当前正在参加的直播间
@@ -42,6 +42,25 @@ def log_screenshot_failed(
pass
def record_room_title_if_not_just_switched(analyser) -> None:
"""run_once_basic 入口:尝试记录当前直播间的标题与位置。
如果刚切换直播间(_just_switched_room=True),跳过重复记录(切换前已记录)。
"""
try:
just_switched = getattr(analyser, "_just_switched_room", False)
if not just_switched:
analyser._record_room_title_and_pos()
else:
analyser._log_kv(
"预约",
"[预约] 刚刚切换直播间,跳过重复记录标题",
reason="avoid_duplicate_after_switch",
)
except Exception:
pass
def dispatch_last_fudai_detail_status(analyser, start_time: float) -> bool:
"""_handle_in_fudai_detail 中根据 _last_fudai_detail_status 分发到对应处理 helper。