 CodexandClaude Opus 4.7
|
b8ccb899c0
|
refactor(fudai): 抽 _handle_in_fudai_detail 步骤1"重新读取详情兜底"块到 reread_fudai_detail_fallback
将"未找到保存的详情数据时的兜底重读"逻辑(约 22 行)抽到 helper:
- 写说明日志
- 调用 read_fudai_detail_with_retries 重新读取
- 成功则更新 _last_fudai_detail_tuple 和 _current_fudai_content
- 返回 detail(成功)或 None(失败)
douyin_fudai.py: 1821 → 1804 行 (-17)
fudai_detail_helpers.py: 2047 → 2083 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 12:09:45 +08:00 |
|
 CodexandClaude Opus 4.7
|
d109e94c68
|
refactor(fudai): 抽 _handle_in_fudai_detail 步骤1"第二次打开直接参与"块到 handle_second_open_direct_attend
将 116 行的"第二次打开使用保存详情直接参与"块抽到 helper:
- 从 _last_fudai_detail_tuple 读取保存的详情
- 设置 _current_fudai_future_ts / _current_fudai_content
- 调用 attend_choujiang 直接参与
- 更新连续失败计数器(成功重置/失败 +1)
- 清除标志 + 写步骤1完成日志
返回值约定:
- True:已完成第二次打开的直接参与处理(调用方应直接 return)
- False:保存的详情数据无效或参与异常,调用方继续兜底逻辑
douyin_fudai.py: 1921 → 1821 行 (-100)
fudai_detail_helpers.py: 1930 → 2047 行
douyin_fudai.py 跌破 1900 行(4121 → 1821,本会话累计削减 2300 行 = -56%)
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 12:07:55 +08:00 |
|
 CodexandClaude Opus 4.7
|
887f8bad3e
|
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>
|
2026-05-22 12:05:29 +08:00 |
|
 CodexandClaude Opus 4.7
|
c2a44f2544
|
refactor(fudai): 抽 _handle_in_fudai_detail 中"高价值福袋记录预约"块到 handle_high_value_record_reservation
将剩余秒数 > 预约参与阈值时的预约记录分支(约 50 行)抽到 helper:
- 写"记录预约"日志(含 reason / value / threshold / remain_seconds)
- 调用 basic_join_decision 记录预约(内部已关闭详情)
- 写完成日志(无论 basic_join_decision 是否成功)
douyin_fudai.py: 1996 → 1962 行 (-34)
fudai_detail_helpers.py: 1809 → 1876 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 12:03:39 +08:00 |
|
 CodexandClaude Opus 4.7
|
f2b5aaa2c4
|
refactor(fudai): 抽 _handle_in_fudai_detail 步骤2"第一次打开数据验证失败"块到 handle_first_open_validation_failed
将 36 行的早返回块抽到 helper:
- 写跳过日志(含 validation_reason)
- 关闭详情页
- 写步骤2完成日志
- clear_task_count_flag
- 写主流程完成日志
douyin_fudai.py: 2020 → 1996 行 (-24)
fudai_detail_helpers.py: 1769 → 1809 行
douyin_fudai.py 跌破 2000 行(4121 → 1996,本会话累计削减 2125 行 = -52%)
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 12:01:22 +08:00 |
|
 CodexandClaude Opus 4.7
|
4f042f95cd
|
refactor(fudai): 抽 _handle_in_fudai_detail 步骤4"参与成功后处理"块到 handle_attend_success_post_processing
将参与成功后的清理逻辑(约 90 行)抽到
fudai_detail_helpers.handle_attend_success_post_processing。逻辑:
- 检查 _last_successful_attend_ts 是否更新
- 从 detail 提取倒计时
- 设置 _waiting_for_lottery_result / _lottery_result_expected_ts
- 调用 handle_reservation_after_attend_success
- 关闭详情页(如未由 attend_choujiang 关闭)
- 清除标志 + 写步骤4完成日志
顺带删除了 1984-1996 行重复 2 次的"清除第一次读取标志"块。
douyin_fudai.py: 2102 → 2020 行 (-82)
fudai_detail_helpers.py: 1678 → 1769 行
douyin_fudai.py 跌破 2100 行(4121 → 2020,本会话累计削减 2101 行 = -51%)
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:59:18 +08:00 |
|
 CodexandClaude Opus 4.7
|
23e24a9f27
|
refactor(fudai): 抽 _handle_live_room_has_or_not_fudai 中"锁定期内时间窗口未到"块到 should_skip_fudai_search_in_lock_period
将 49 行的早返回检查抽到 helper:
- focus_until > now_ts(在锁定期内)
- queue_full_waiting_at_earliest=True
- 队头预约 future_ts - join_ahead > now_ts → 跳过查找避免重复打开详情
返回值约定:
- True:满足跳过条件,已写完成日志,调用方应直接 return
- False:不满足,调用方继续正常流程
douyin_fudai.py: 2144 → 2102 行 (-42)
fudai_detail_helpers.py: 1614 → 1678 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:56:51 +08:00 |
|
 CodexandClaude Opus 4.7
|
c5a70d4a62
|
refactor(fudai): 抽 _handle_in_fudai_detail 中"参与成功后预约处理"块到 handle_reservation_after_attend_success
将参与成功后的预约清理逻辑(约 116 行)抽到
fudai_detail_helpers.handle_reservation_after_attend_success。逻辑:
- 如果还有其他预约:设置 10 秒保护期确保依次参与
- 如果没有其他预约:清除锁定期
- 从队列中移除当前刚完成的预约(5 秒误差匹配)
- 重新排序剩余队列
douyin_fudai.py: 2260 → 2144 行 (-116)
fudai_detail_helpers.py: 1495 → 1614 行
douyin_fudai.py 跌破 2200 行(4121 → 2144,本会话累计削减 1977 行 = -48%)
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:54:02 +08:00 |
|
 CodexandClaude Opus 4.7
|
3de07d7a66
|
refactor(fudai): 抽 _handle_in_fudai_detail 中"简单跳过状态"的 3 个分支到 handle_simple_skip_status
last_status == "coupon_popup" / "watch_task" / "validation_failed" 三个分支
结构完全相同(写日志 → clear_task_count_flag → 写完成日志 → return),
统一抽到 handle_simple_skip_status 通用模板。
douyin_fudai.py: 2281 → 2260 行 (-21)
fudai_detail_helpers.py: 1468 → 1495 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:51:39 +08:00 |
|
 CodexandClaude Opus 4.7
|
d35fadde54
|
refactor(fudai): 复用 fallback_swipe_up_to_next_live helper 替换"task_count_zero 连续失败"分支重复代码
_handle_in_fudai_detail 中"连续3次任务数量为0"分支也有 65 行结构完全相同的
兜底 ADB 上滑逻辑(与上一 commit 抽出的 fallback_swipe_up_to_next_live 完全一致),
复用同一个 helper。
douyin_fudai.py: 2336 → 2281 行 (-55)
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:49:39 +08:00 |
|
 CodexandClaude Opus 4.7
|
241c35f21d
|
refactor(fudai): 抽 _handle_in_fudai_detail 中"兜底上滑切房"块到 fallback_swipe_up_to_next_live
将筛选不通过后的兜底切换逻辑(67 行深度嵌套)抽到
fudai_detail_helpers.fallback_swipe_up_to_next_live。逻辑:
- 优先 swipe_up_to_next_live
- 兜底直接调用 ADB shell input swipe(基于 1080x2400 基准坐标缩放)
- 最终回退到 operation.swipe
douyin_fudai.py: 2400 → 2336 行 (-64)
fudai_detail_helpers.py: 1403 → 1468 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:47:44 +08:00 |
|
 CodexandClaude Opus 4.7
|
1468d14d0e
|
refactor(fudai): 抽 _handle_in_fudai_detail 入口诊断日志到 log_handle_in_fudai_detail_entry
将 17 行的入口 flags 日志(reservation_after_action_pending /
reservation_focus_until_ts / waiting_for_lottery / room_pos)抽到
fudai_detail_helpers.log_handle_in_fudai_detail_entry。
douyin_fudai.py: 2412 → 2400 行 (-12)
fudai_detail_helpers.py: 1382 → 1403 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:41:52 +08:00 |
|
 CodexandClaude Opus 4.7
|
45f925b597
|
refactor(fudai): 抽 run_once_basic 中"截图+阶段诊断"块到 take_screenshot_and_diagnose
将步骤 1(截图最多 3 次重试 + 阶段诊断 + 写日志)独立块(约 64 行)抽到
fudai_detail_helpers.take_screenshot_and_diagnose。
返回值约定:
- (stage, seen) 二元组:截图成功,调用方继续后续流程
- None:截图失败已写完成日志,调用方应直接 return
douyin_fudai.py: 2468 → 2412 行 (-56)
fudai_detail_helpers.py: 1311 → 1382 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:39:38 +08:00 |
|
 CodexandClaude Opus 4.7
|
e21e5a5fca
|
refactor(fudai): 抽 run_once_basic 中"第一个预约检查日志"块到 log_first_reservation_check
将 40 行的纯日志块抽到 fudai_detail_helpers.log_first_reservation_check。
输出 needswitch 配置 + 队列长度 + 第一个预约的详细信息(future_ts、
剩余秒数、目标位置等)。
douyin_fudai.py: 2503 → 2468 行 (-35)
fudai_detail_helpers.py: 1266 → 1311 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:37:35 +08:00 |
|
 CodexandClaude Opus 4.7
|
7694e233f9
|
refactor(fudai): 抽 run_once_basic 中"预约回退触发条件日志"块到 log_reservation_check_status
将 65 行的纯日志块抽到 fudai_detail_helpers.log_reservation_check_status。
输出 3 类日志(无副作用):
1. 触发条件详情(含队列前 3 项)
2. high_value_enabled=False 时的提示
3. 队列为空时的提示
douyin_fudai.py: 2558 → 2503 行 (-55)
fudai_detail_helpers.py: 1198 → 1266 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:33:37 +08:00 |
|
 CodexandClaude Opus 4.7
|
a90a885a51
|
refactor(fudai): 抽 run_once_basic 中"预约状态文件写入"闭包到 write_reservations_state_throttled
将 run_once_basic 中的 _write_state 内联闭包(约 87 行)抽到模块级
fudai_detail_helpers.write_reservations_state_throttled。该闭包:
- 节流(1 秒内重复调用直接返回)避免高频写盘卡顿
- 格式化 reservations 为 dict 列表 + 写 JSON 状态文件
主文件中保留薄包装的 _write_state 闭包仅一行调用 helper,
保持原有签名供 process_reservation_attend_window 等回调使用。
douyin_fudai.py: 2638 → 2558 行 (-80)
fudai_detail_helpers.py: 1115 → 1198 行
douyin_fudai.py 跌破 2600 行(4121 → 2558,本会话累计削减 1563 行 = -38%)
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:31:12 +08:00 |
|
 CodexandClaude Opus 4.7
|
48f4af5848
|
refactor(fudai): 抽 run_once_basic 中"初始化预约队列"块到 initialize_reservations_queue
将 run_once_basic 步骤 0.1.1"第一次运行:清空预约队列 + 写状态文件"
独立块(约 122 行)抽到 fudai_detail_helpers.initialize_reservations_queue。
逻辑:
- 第一次运行:reservations = [] + 写空队列到状态文件 + _first_run_once_basic = False
- 非第一次:保留当前队列,仅记录调试日志
douyin_fudai.py: 2755 → 2638 行 (-117)
fudai_detail_helpers.py: 993 → 1115 行
douyin_fudai.py 跌破 2700 行(4121 → 2638,本会话累计削减 1483 行 = -36%)
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:26:14 +08:00 |
|
 CodexandClaude Opus 4.7
|
3af7c6d894
|
style(fudai): 删除 run_once_basic 中重复的注释行
提取 try_wait_for_lottery_result 时遗留了一行重复的步骤 0 注释。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:24:04 +08:00 |
|
 CodexandClaude Opus 4.7
|
6f796a8aaf
|
refactor(fudai): 抽 run_once_basic 中"等待开奖持续 OCR 检测"块到 try_wait_for_lottery_result
将 run_once_basic 步骤 0"如果正在等待开奖,持续 OCR 检测开奖结果"独立块
(约 161 行)抽到 fudai_detail_helpers.try_wait_for_lottery_result。逻辑:
- 超时(future_ts + 10s):清除等待标志,调用方继续后续流程
- 持续轮询 OCR:命中 → 处理结果 + 写完成日志 + return
- 轮询结束未命中:清除标志 + 按 needswitch 切换 + return
返回值约定:
- True:已处理开奖等待路径并写完成日志(调用方应直接 return)
- False:未在等待开奖或超时立即清除(调用方继续)
douyin_fudai.py: 2910 → 2756 行 (-154)
fudai_detail_helpers.py: 819 → 993 行
douyin_fudai.py 跌破 2800 行(4121 → 2756,本会话累计削减 1365 行)
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:21:51 +08:00 |
|
 CodexandClaude Opus 4.7
|
e351745e92
|
refactor(fudai): 抽 run_once_basic 中"30分钟超时检查"块到 try_no_attend_timeout
将步骤 0"30分钟未参与成功福袋则返回推荐页"独立块(约 68 行)抽到
fudai_detail_helpers.try_no_attend_timeout。逻辑:
- 如果距离 _last_successful_attend_ts > _no_attend_timeout_minutes 触发
- 如果从未参与且运行时长 > _no_attend_timeout_minutes 触发
- 触发时调用 _return_to_recommend_and_reenter_live + 写完成日志
返回值约定:
- True:触发超时处理,调用方应直接 return
- False:未触发,调用方继续
douyin_fudai.py: 2971 → 2910 行 (-61)
fudai_detail_helpers.py: 745 → 819 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:19:53 +08:00 |
|
 CodexandClaude Opus 4.7
|
0114af2321
|
refactor(fudai): 抽 run_once_basic 中"跳过阶段检测"块到 try_skip_stage_diagnosis
将步骤 0.5"点击参与抽奖后跳过阶段检测,直接查找福袋"独立块(约 19 行)
抽到 fudai_detail_helpers.try_skip_stage_diagnosis。
返回值约定:
- True:跳过阶段检测路径完成,调用方应直接 return
- False:正常流程,继续阶段检测
douyin_fudai.py: 2983 → 2971 行 (-12)
fudai_detail_helpers.py: 716 → 745 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:18:18 +08:00 |
|
 CodexandClaude Opus 4.7
|
849160304e
|
refactor(fudai): 抽 run_once_basic 中"刚记录预约后切换直播间"块到 try_just_recorded_reservation_switch
将 run_once_basic 步骤"检查是否刚刚记录了预约,如果是则强制切换直播间"
独立块(约 47 行)抽到 fudai_detail_helpers.try_just_recorded_reservation_switch。
返回值约定:
- True:刚记录预约,已尝试切换并写完成日志(调用方应直接 return)
- False:未触发,调用方继续正常流程
douyin_fudai.py: 3022 → 2983 行 (-39)
fudai_detail_helpers.py: 657 → 716 行
douyin_fudai.py 跌破 3000 行(4121 → 2983,本会话累计削减 1138 行)
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:16:38 +08:00 |
|
 CodexandClaude Opus 4.7
|
7307b2abb5
|
refactor(fudai): 抽 run_once_basic 中"COUPON_POPUP"和"SHOPPING_REDPACKET_POPUP"分支到 helper
将两个简单的弹窗处理分支抽到独立 helper:
- handle_coupon_popup:按返回键关闭优惠券弹窗
- handle_shopping_redpacket_popup:点击 (530, 1647) 关闭购物红包弹窗
douyin_fudai.py: 3042 → 3022 行 (-20)
fudai_detail_helpers.py: 618 → 657 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:14:54 +08:00 |
|
 CodexandClaude Opus 4.7
|
c9a07cc91e
|
refactor(fudai): 抽 run_once_basic 中"IN_LIVE_ROOM"分支到 handle_in_live_room_stage
将"在直播间"阶段的处理逻辑(约 44 行)抽到
fudai_detail_helpers.handle_in_live_room_stage。逻辑:
- 如果刚切换直播间(_just_switched_room=True),等待福袋加载
(switch_room_wait_after_stage_diag_seconds 秒)
- 调用 _handle_live_room_has_or_not_fudai 寻找福袋图标
- 写完成日志
douyin_fudai.py: 3071 → 3042 行 (-29)
fudai_detail_helpers.py: 572 → 618 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:12:21 +08:00 |
|
 CodexandClaude Opus 4.7
|
b5d7943af0
|
refactor(fudai): 抽 run_once_basic 中"FUDai_RESULT"分支到 handle_lottery_result_stage
将抽奖结果弹窗处理独立块(约 30 行)抽到
fudai_detail_helpers.handle_lottery_result_stage。逻辑:
- 清除 _waiting_for_lottery_result / _current_attending_reservation_fudai
- OCR 识别开奖结果文本
- 命中则 _handle_lottery_result_by_ocr;未命中则返回键 + 切下个直播间
- 写完成日志
douyin_fudai.py: 3092 → 3071 行 (-21)
fudai_detail_helpers.py: 535 → 572 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:10:48 +08:00 |
|
 CodexandClaude Opus 4.7
|
da552d18cc
|
refactor(fudai): 抽 run_once_basic 中"RECOMMEND_PAGE"分支到 handle_recommend_page
将识别到推荐页面后的处理逻辑(约 56 行)抽到
fudai_detail_helpers.handle_recommend_page。逻辑:
- 点击进入直播页 (718, 169)
- 连点两次进入直播间 (103, 382)
- 多段延迟(FOLLOW_TAB_CLICK_DELAY / ENTER_LIVE_CLICK_DELAY /
RETURN_STEP_DELAY_SECONDS / ENTER_LIVE_FINAL_DELAY)
- 异常时按返回键 + delay 1s
douyin_fudai.py: 3132 → 3092 行 (-40)
fudai_detail_helpers.py: 477 → 535 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:09:26 +08:00 |
|
 CodexandClaude Opus 4.7
|
40b4169aac
|
refactor(fudai): 抽 run_once_basic 中"桌面自救检测"块到 try_desktop_recovery
将 run_once_basic 步骤 1.5 桌面自救独立块(约 95 行)抽到
fudai_detail_helpers.try_desktop_recovery。
返回值约定:
- True:检测到不在抖音前台,已尝试自救并递归调用 run_once_basic
(调用方应直接 return)
- False:在抖音前台或检测异常,调用方继续正常流程
douyin_fudai.py: 3220 → 3132 行 (-88)
fudai_detail_helpers.py: 372 → 477 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:07:34 +08:00 |
|
 CodexandClaude Opus 4.7
|
265a533cf0
|
refactor(fudai): 抽 run_once_basic 中"高价值房间重访"块到 try_high_value_room_revisit
将 run_once_basic 步骤 2.0 高价值房间重访检查独立块(约 78 行)抽到
fudai_detail_helpers.try_high_value_room_revisit。
返回值约定:
- True:重访成功,调用方应直接 return(结束本轮 run_once_basic)
- False:未触发或重访失败,调用方继续正常流程
douyin_fudai.py: 3290 → 3220 行 (-70)
fudai_detail_helpers.py: 284 → 372 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:06:09 +08:00 |
|
 CodexandClaude Opus 4.7
|
37b3454e32
|
refactor(fudai): 抽 run_once_basic 中"FANSCLUB_JOIN"分支到 handle_fansclub_join
将 run_once_basic 中"粉丝团加入"分支(约 164 行)整段抽到
fudai_detail_helpers.handle_fansclub_join。逻辑:
- 第一步:点击参与按钮(基于 OCR 区域中心 543, 2070)
- 第二步:连续两次点击预设位置(527, 567)
- 第三步:关闭详情页(点击 500, 470)
- 异常分支:按 auto_join_fansclub 决定是否再次诊断 + 重试 + 点击返回
- 最终:按 fansclub_fail_action 决定是否切换直播间
douyin_fudai.py: 3447 → 3290 行 (-157)
fudai_detail_helpers.py: 120 → 284 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:02:56 +08:00 |
|
 CodexandClaude Opus 4.7
|
77351bafd4
|
refactor(fudai): 抽 run_once_basic 中"截图失败多次重试"日志块到 log_screenshot_failed
将 run_once_basic 中"获取截图失败(多次重试后仍失败)"的多字段日志块
(22 行)抽到 fudai_detail_helpers.log_screenshot_failed。
douyin_fudai.py: 3460 → 3447 行 (-13)
fudai_detail_helpers.py: 83 → 120 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 11:00:56 +08:00 |
|
 CodexandClaude Opus 4.7
|
9675df2cdb
|
refactor(fudai): 抽 _handle_in_fudai_detail 中重复的"清除任务数量标志"块到 clear_task_count_flag
_handle_in_fudai_detail 中有 11 处结构完全相同的"清除任务数量标志"
try/except 嵌套块(每处 12 行),统一抽到 clear_task_count_flag helper。
逻辑:set _fudai_detail_task_count_from_stage = None + log_kv("福袋详情",
"_handle_in_fudai_detail:清除任务数量标志", log_type="DEBUG")。
douyin_fudai.py: 3588 → 3460 行 (-128)
fudai_detail_helpers.py: 63 → 83 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 10:57:59 +08:00 |
|
 CodexandClaude Opus 4.7
|
d34e39ec9c
|
refactor(fudai): 抽 _handle_in_fudai_detail 中"连续参与失败次数过多"块到 fudai_detail_helpers
将 49 行的"连续参与失败兜底"块抽到 fudai_modules/fudai_detail_helpers.py:
handle_consecutive_failures_exceeded。逻辑:
- 写日志 + 关闭详情页
- 按 needswitch 切换直播间或保持单间模式
- 重置 _consecutive_attend_failures 计数器
douyin_fudai.py: 3627 → 3588 行 (-39)
新增 fudai_detail_helpers.py: 63 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 10:52:59 +08:00 |
|
 CodexandClaude Opus 4.7
|
34bdf44d73
|
refactor(fudai): 抽 attend_choujiang 中"开始观看"/"参与"分支用 handle_simple_click
新增 handle_simple_click 通用模板,覆盖结构完全相同的 2 个分支:
- "开始观看" → click(543, 2070) + log + return True
- "参与" → click(543, 2070) + log + return True
每个分支原本 11 行(含坐标注释),合并后 4 行调用。
fudai_attend.py: 1309 → 1295 行 (-14)
fudai_attend_branches.py: 349 → 366 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 10:49:21 +08:00 |
|
 CodexandClaude Opus 4.7
|
6f4dbb2d8b
|
refactor(fudai): 抽 attend_choujiang 中"评论"和"参与抽奖"分支到 handle_attend_click
将 attend_choujiang 中两个结构高度重叠的"点击参与按钮"分支抽到通用
handle_attend_click(analyser, mode) helper:
- 评论模式:仅点击 + 记 metric,return True
- 参与抽奖模式(mode="普通"):额外
- 设置 _skip_stage_diagnosis_and_find_fudai 标志
- 写 debug log(开始设置等待开奖标志)
- 设置 _waiting_for_lottery_result / _lottery_result_expected_ts
- 写 debug log(成功设置等待开奖标志)
fudai_attend.py: 1446 → 1309 行 (-137)
fudai_attend_branches.py: 217 → 349 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 10:47:24 +08:00 |
|
 CodexandClaude Opus 4.7
|
4e89fadd2e
|
refactor(stage): 提取"步骤2.5 购物红包OCR复查"块到 verify_redpacket_outside_live_room
将 douyin_stage.py 中"不在直播间但像素检测到购物红包背景"的 OCR 复查
独立块(约 153 行)抽到 douyin_stage_helpers.verify_redpacket_outside_live_room。
逻辑:
- 截图 SHOPPING_REDPACKET_AREA
- OCR 模式0 → 关键词未命中且 enable_ocr_mode1 → 跑模式1
- 关键词匹配 OR 置信度 ≥ shopping_redpacket_ocr_confidence_threshold → 判定
依赖通过参数注入:pixel_state、pixel_details、enable_ocr_mode1、
max_step_time、diag_start、_log/_log_summary、preprocess_for_ocr。
douyin_stage.py: 1247 → 1111 行 (-136)
douyin_stage_helpers.py: 199 → 383 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 10:40:26 +08:00 |
|
 CodexandClaude Opus 4.7
|
331860ee5c
|
refactor(reservation): 抽 attend_window 中 2 个时间窗口日志块
将 process_reservation_attend_window 中两个纯日志块抽到 helper:
- log_time_window_not_yet:时间窗口未到,跳过回退
- log_missed_window:已明显错过开奖时间,记录 missed_seconds
attend_window.py: 1276 → 1247 行 (-29)
attend_window_helpers.py: 276 → 329 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 10:35:18 +08:00 |
|
 CodexandClaude Opus 4.7
|
4abd053957
|
refactor(reservation): 抽 attend_window 的"详细检查日志"块到 log_attend_window_detail_check
将 process_reservation_attend_window 中"详细调试日志"块(约 50 行)抽到
log_attend_window_detail_check helper。该块仅做日志输出,无副作用,
依赖通过参数注入:now_ts / focus_until / ft / dynamic_ahead / join_ahead /
poll_before / est_back_times。
attend_window.py: 1314 → 1276 行 (-38)
attend_window_helpers.py: 213 → 276 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 10:33:35 +08:00 |
|
 CodexandClaude Opus 4.7
|
8fea99a168
|
refactor(reservation): 抽 attend_window 的"锁定期处理"块到 process_lock_period
将 process_reservation_attend_window 中"锁定期内:优先处理锁定的预约"
独立块(51 行)抽到 process_lock_period helper。逻辑:
- 在 reservations 中找与 focus_until 对应的预约(误差 ≤5 秒)
- 找不到 → 视为锁定失效,清除 focus_until_ts_ref,返回 0.0
- 找到但不在队头 → 移到队头,返回原 focus_until
- 已在队头 → 不动,返回原 focus_until
attend_window.py: 1352 → 1314 行 (-38)
attend_window_helpers.py: 143 → 213 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 10:31:53 +08:00 |
|
 CodexandClaude Opus 4.7
|
51d859150d
|
refactor(reservation): 抽 attend_window 中重复的"超时检查"模式到 check_total_timeout
process_reservation_attend_window 内有 2 处结构完全相同的超时检查块
("排序前"和"排序后"),各 13 行。统一抽到 check_total_timeout helper,
通过 stage_label 参数区分日志。
attend_window.py: 1372 → 1352 行 (-20)
attend_window_helpers.py: 116 → 143 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 10:30:32 +08:00 |
|
 CodexandClaude Opus 4.7
|
c509bf1262
|
refactor(reservation): 提取 attend_window 中 2 个早返回块到 attend_window_helpers
将 process_reservation_attend_window 中两个结构相同的早返回块抽出:
- handle_already_participated:检测到 ft 已被参与,移除队头并写状态
- handle_invalid_future_ts:future_ts ≤ 0,丢弃队头并写状态
新增私有 _write_state_unified 封装"safe_write_state vs 裸 callback"
两条路径,避免主流程重复 if/else。
attend_window.py: 1437 → 1372 行 (-65)
新增 attend_window_helpers.py: 116 行
验证:
- pytest 1013 passed
- compile OK
- stub 调用两条早返回路径均返回 False
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 10:28:50 +08:00 |
|
 CodexandClaude Opus 4.7
|
3b600c9f64
|
fix(reservation): 补 _RESERVATION_ERROR_UTILS_AVAILABLE import 修复运行时 NameError
attend_window.py 中 9 处使用 _RESERVATION_ERROR_UTILS_AVAILABLE 标志,
但 import 语句只导入了 ReservationItem / format_reservation_context /
log_reservation_error / safe_write_state,没有导入这个标志。
发现路径:尝试为该文件提取 helper 时,stub 测试触发到第 360 行的
"future_ts 无效"分支,立即抛出 NameError。
原代码中此分支被 try/except 覆盖的概率较高(外层 try 会吞噬),
但只要执行流落在 line 64/95/113/167/296/360/371/...(共 9 处)
任意一个 if 判断上,就会 NameError。
修复:把 _RESERVATION_ERROR_UTILS_AVAILABLE 加入 ._common 的
import 列表。
验证:
- stub 测试通过
- pytest 1013 passed
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 10:27:21 +08:00 |
|
 CodexandClaude Opus 4.7
|
d7201866a5
|
refactor(stage): 提取 diagnose_stage_from_current_screen 中"步骤3 OCR确认弹窗"块到 douyin_stage_helpers
将 1203-1359 行(约 157 行)的"OCR弹窗确认"独立块抽到
douyin/stage/douyin_stage_helpers.py:verify_popup_via_ocr。
该块当所有像素检测都未命中特定阶段、但像素检测到弹窗背景特征时
执行 OCR 二次确认(优惠券"开心收下"/购物红包关键词)。
依赖通过参数注入:pixel_state、enable_ocr_mode1、max_step_time、
diag_start、max_diag_time、_log/_log_summary 闭包、preprocess_for_ocr。
douyin_stage.py: 1385 → 1247 行 (-138)
新增 douyin_stage_helpers.py: 199 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 10:22:07 +08:00 |
|
 CodexandClaude Opus 4.7
|
a3fe7b3ef0
|
refactor(fudai): 抽 attend_choujiang 中 3 个简单失败分支用通用 helper
新增 handle_simple_fail 通用模板,覆盖结构完全相同的 3 个分支:
- watch_required(还需看播)
- cannot_participate(无法参与)
- watch_duration_insufficient(时长不足)
每个分支的逻辑都是:set fail_reason → log → metric → click(500,470) → return False。
fudai_attend.py: 1471 → 1446 行 (-25)
fudai_attend_branches.py: 184 → 217 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 10:19:14 +08:00 |
|
 CodexandClaude Opus 4.7
|
1c1f0abfc0
|
refactor(fudai): 提取 attend_choujiang 中 4 个独立分支到 fudai_attend_branches
将 attend_choujiang 内 4 个 button_text 命中的早返回分支抽出:
- handle_no_parallel_ocr:并行OCR结果不可用
- handle_condition_not_met:不满足参与条件
- handle_attend_already_success:已参与/参与成功
- handle_activity_ended:活动已结束/福袋超时
每个 helper 处理一个分支并返回 True/False,与原代码 return 值一致。
fudai_attend.py: 1629 → 1471 行 (-158)
新增 fudai_attend_branches.py: 184 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 08:08:16 +08:00 |
|
 CodexandClaude Opus 4.7
|
5d2a0ac3ff
|
refactor(fudai): 提取 __init__ 中默认配置块到 fudai_init_defaults
将 fudai_analyse.__init__ 中 137 行简单的 self.X = literal 配置默认值赋值
统一抽到 fudai_modules/fudai_init_defaults.py 的 init_default_config 函数。
所有字段语义、默认值、类型注解保持完全一致;load_config() 仍然会用
config.json 覆盖这些默认值。
douyin_fudai.py: 3760 → 3627 行 (-133)
新增 fudai_init_defaults.py: 132 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 08:04:31 +08:00 |
|
 CodexandClaude Opus 4.7
|
c8df6a1588
|
refactor(fudai): 提取 fudai_choujiang 中 3 个独立子块到 fudai_choujiang_helpers
将 douyin_fudai.py:fudai_choujiang 内 3 个无业务状态依赖的独立块抽出:
- cleanup_stale_screenshot:启动时清理旧截图
- resolve_device_resolution:分辨率解析(5 次重试 + 默认回退)
- write_actions_log:写运行起止标记到 actions.log(原代码重复 3 次)
douyin_fudai.py: 3861 → 3760 行 (-101)
新增 fudai_choujiang_helpers.py: 97 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 08:01:51 +08:00 |
|
 CodexandClaude Opus 4.7
|
b1ee0e6b4e
|
refactor(fudai): 提取 _capture_roi_screenshot 和 _match_icon_template 到 fudai_image_helpers
将 douyin_fudai.py 中两个图像处理工具方法(共 274 行)提取为
fudai_modules/fudai_image_helpers.py 模块级函数:
- capture_roi_screenshot(analyser, ...)
- match_icon_template(analyser, ...)
类内保留薄包装方法,调用签名不变,外部调用方(douyin_yanghao.py)
无需改动。
douyin_fudai.py: 4121 → 3861 行 (-260)
新增 fudai_image_helpers.py: 281 行
验证:
- pytest 1013 passed
- compile OK
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 07:59:24 +08:00 |
|
 CodexandClaude Opus 4.7
|
b9f0389e58
|
chore(finder): 删除 check_have_fudai_with_ready_screenshot 中 return False 之后的不可达死代码
第 938-1431 行(共 494 行)位于函数 return 语句之后,永远不会执行。
这是早期像素检测改用模板匹配后的遗留代码。函数末尾的模块级注释
"像素检测代码已删除,使用模板匹配替代" 已说明该段代码无用。
验证:
- AST 解析通过
- pytest 1013 passed
- 函数边界从 19-1431 缩到 19-936
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 07:54:25 +08:00 |
|
 CodexandClaude Opus 4.5
|
66eb05e6b1
|
补 reservation_logic.cleanup_validate 子模块单元测试(+10 用例)
- validate_back_to_reservation / cleanup_expired_reservations 函数签名验证
- reservation_logic 全部 6 个子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-22 01:22:56 +08:00 |
|
 CodexandClaude Opus 4.5
|
5a40b49727
|
补 douyin_yanghao_pkg 剩余子模块单元测试(+7 用例)
- _scaled_click / _do_comment 函数签名验证
- douyin_yanghao_pkg 全部 3 个子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:48:38 +08:00 |
|