diff --git a/douyin/core/douyin_fudai.py b/douyin/core/douyin_fudai.py index f19a1f5..4f99a52 100644 --- a/douyin/core/douyin_fudai.py +++ b/douyin/core/douyin_fudai.py @@ -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: # 筛选检查异常,记录日志但继续流程 diff --git a/douyin/core/fudai_modules/fudai_detail_helpers.py b/douyin/core/fudai_modules/fudai_detail_helpers.py index fbe2137..96fe18c 100644 --- a/douyin/core/fudai_modules/fudai_detail_helpers.py +++ b/douyin/core/fudai_modules/fudai_detail_helpers.py @@ -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,