refactor(fudai): 抽 _handle_in_fudai_detail 中"筛选不通过"块到 handle_filter_skip
将筛选不通过分支(约 50 行)抽到 helper: - 写"筛选不通过"日志 - 关闭详情页 - 按 needswitch 切换直播间 - clear_task_count_flag - 写完成日志 douyin_fudai.py: 1962 → 1921 行 (-41) fudai_detail_helpers.py: 1876 → 1930 行 验证: - pytest 1013 passed - compile OK Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
c2a44f2544
commit
887f8bad3e
2 files changed
+58
-45
No files matched your search
@@ -1521,52 +1521,11 @@ class fudai_analyse:
|
||||
|
||||
# 如果不是高价值福袋,或者不是倒计时原因,筛选不通过,直接跳过
|
||||
if skip:
|
||||
try:
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail:第一次打开时筛选不通过,直接跳过",
|
||||
skip_reason=skip_reason,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
# 关闭详情页
|
||||
try:
|
||||
douyin_fudai_detail.close_fudai_detail(self)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 如果允许切换直播间,筛选不通过直接切换直播间
|
||||
try:
|
||||
needswitch = bool(getattr(self, "needswitch", True))
|
||||
except Exception:
|
||||
needswitch = True
|
||||
if needswitch:
|
||||
try:
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail:筛选不通过后切换直播间",
|
||||
skip_reason=skip_reason,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
from douyin.core.fudai_modules.fudai_detail_helpers import (
|
||||
fallback_swipe_up_to_next_live,
|
||||
)
|
||||
|
||||
fallback_swipe_up_to_next_live(self)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 清除任务数量标志
|
||||
clear_task_count_flag(self)
|
||||
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(筛选不通过)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
from douyin.core.fudai_modules.fudai_detail_helpers import (
|
||||
handle_filter_skip,
|
||||
)
|
||||
|
||||
handle_filter_skip(self, skip_reason, start_time)
|
||||
return
|
||||
except Exception as e:
|
||||
# 筛选检查异常,记录日志但继续流程
|
||||
|
||||
@@ -42,6 +42,60 @@ def log_screenshot_failed(
|
||||
pass
|
||||
|
||||
|
||||
def handle_filter_skip(analyser, skip_reason: str, start_time: float) -> None:
|
||||
"""_handle_in_fudai_detail 筛选不通过分支:关闭详情 + 按 needswitch 切换直播间。
|
||||
|
||||
流程:
|
||||
1. 写"第一次打开时筛选不通过"日志
|
||||
2. 关闭详情页
|
||||
3. 如果 needswitch=True:写日志 + fallback_swipe_up_to_next_live
|
||||
4. clear_task_count_flag
|
||||
5. 写完成日志(调用方 return)
|
||||
"""
|
||||
from douyin.fudai import douyin_fudai_detail
|
||||
|
||||
try:
|
||||
analyser._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail:第一次打开时筛选不通过,直接跳过",
|
||||
skip_reason=skip_reason,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
douyin_fudai_detail.close_fudai_detail(analyser)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
needswitch = bool(getattr(analyser, "needswitch", True))
|
||||
except Exception:
|
||||
needswitch = True
|
||||
|
||||
if needswitch:
|
||||
try:
|
||||
analyser._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail:筛选不通过后切换直播间",
|
||||
skip_reason=skip_reason,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
fallback_swipe_up_to_next_live(analyser)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
clear_task_count_flag(analyser)
|
||||
|
||||
elapsed = time.time() - start_time
|
||||
analyser._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(筛选不通过)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
|
||||
|
||||
def handle_high_value_record_reservation(
|
||||
analyser,
|
||||
detail,
|
||||
|
||||
Reference in new issue
Block a user