 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
|
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
|
a337b4b93d
|
underlying_operations 第三轮拆分(2434 → 2351,再瘦身 83 行)
新增 2 个子模块:
- device_select (新, 73) select_device 设备选择交互(无 self.X)
- ocr_digits (新, 49) analyse_pic_digits 数字 OCR 识别
(保留 analyser 参数以调 analyser.analyse_pic_word)
策略:
- select_device 的 self.X 全是 _adb_path / _adb_args,已经是 module-level,
搬出后改用 from .adb_helpers import _adb_path, _adb_args 即可。
- analyse_pic_digits 用 self.analyse_pic_word(递归调用类内大方法)。
搬到 module-level 后第一参数从 self 改名 analyser,类内 forwarding
传 self 即可,外部 op.analyse_pic_digits(picname) 完全兼容。
回归:
- 4 个新/改文件 compileall 通过
- pytest 353 passed / 1 skipped
- underlying_operations.select_device / analyse_pic_digits 类方法和 module-level
函数都可访问
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 20:12:40 +08:00 |
|
 CodexandClaude Opus 4.7
|
57eacb3219
|
underlying_operations 第二轮拆分(2582 → 2434,再瘦身 148 行)
新增 3 个子模块 + 1 个函数搬到已有子模块:
- adb_helpers (38) 新增 _adb_args(构造 adb -s 命令行)
- reward_pic (新, 73) save_reward_pic(中奖截图保存)
- swipe_sendevent (新, 47) _swipe_with_sendevent_improved(sendevent 滑动)
- clipboard (新, 75) set_clipboard_text(设备剪贴板设置)
策略:4 个方法的 self.X 引用都是 self._adb_path / self._adb_args 这种
"无状态工具方法",可以替换为 module-level 函数调用。类内方法保留为
1 行 forwarding 调用 _impl_X。
外部调用全部不需修改:
- save_reward_pic 4 处外部 self.save_reward_pic 仍工作
- _adb_args / _swipe_with_sendevent_improved / set_clipboard_text 0 外部引用
回归:
- 5 个新/改文件 compileall 通过
- pytest 353 passed / 1 skipped
- 类的 _adb_args / save_reward_pic / set_clipboard_text /
_swipe_with_sendevent_improved 4 个 forwarding 全部正确
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 20:07:23 +08:00 |
|
 CodexandClaude Opus 4.7
|
254820e6dc
|
拆分 underlying_operations (3021 → 5 子模块 + 2582 行原文件)
把 douyin/core/underlying_operations.py 中 6 个零 self 引用的方法搬到
douyin/core/underlying_operations_pkg/ 子包,类内方法变成 1 行 forwarding。
原文件保留 underlying_operations 巨型类(>50 个实例方法用 self)。
新建子包:
- adb_helpers (34) _adb_path / _pick_adbkeyboard_ime
- pic_path (65) _find_pic_path 按名称查找图片路径
- ocr_content (228) extract_ocr_content OCR 文本拼接 + 置信度
- countdown (179) check_countdown 倒计时文本解析(含 OCR 字符纠错)
- bounds (17) _parse_bounds 解析 UI dump 的 [x1,y1][x2,y2]
策略:6 个方法的 self 引用全为 0,纯算法逻辑直接搬到 module-level;
类内对应方法保留装饰器和签名,body 改为 1 行 forwarding 调用:
@staticmethod
def _adb_path() -> str:
return _impl_adb_path()
外部调用全部不需修改:
- ``self._find_pic_path(...)`` 实例方法 forwarding 仍工作
- ``cls._adb_path()`` staticmethod forwarding 仍工作
- ``ReservationHandler._parse_bounds(...)`` 外部 5 处引用零修改
修复发现:
- countdown.py 原本 ``import datetime``(应为 ``from datetime import datetime,
timedelta``),导致 datetime.now()/timedelta() 触发 NameError 后被外层
except 吞掉返回 False。修正后 check_countdown('5:30') 正确返回 (330, <ts>)
- 子模块内部用 _uo_log,加本地实现避免对原文件的循环依赖
回归:
- 6 个新文件 + 改写后 underlying_operations.py compileall 通过
- pytest 353 passed / 1 skipped
- check_countdown / extract_ocr_content / _parse_bounds /
_pick_adbkeyboard_ime / _find_pic_path / _adb_path 6 个 forwarding 全部正确
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 19:54:22 +08:00 |
|
 CodexandClaude Opus 4.7
|
badf64998d
|
拆分 douyin_flow_control (706 → 4 个子模块 + 23 行 shim)
把 douyin/core/douyin_flow_control.py 4 个独立顶层函数拆成
douyin/core/douyin_flow_control_pkg/ 子包:
- stage_handler (34) handle_stage_after_diagnosis 阶段后状态记录
- find_open (537) find_and_open_fudai_detail 找福袋并打开详情(最大头)
- filter (85) filter_fudai_detail 配置筛选决策
- no_fudai (94) handle_no_fudai_situation 无福袋时的简单流程
原文件改为 23 行 re-export shim,4 个公共符号全部保留。
- find_and_open_fudai_detail 4 处外部引用,其他 0 处
全部不需修改。
回归:
- 5 个新文件 + shim compileall 通过
- pytest 353 passed / 1 skipped
- 旧 import 路径与新子包路径返回同一函数对象
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 19:03:43 +08:00 |
|
 CodexandClaude Opus 4.7
|
c5c8def884
|
underlying_operations: 52 处 print → _uo_log
- 新增模块级 _uo_log(msg, level):与项目其他 print→logger 改造一致的模式,
优先走 logging(带 [OCR]/[截图]/[Underlying]/[警告]/[错误] 前缀),失败兜底 stdout
- 替换的内容包括:
- OCR 引擎初始化 / 延迟初始化(PaddleOCR / EasyOCR 切换)
- exec-out 截图 / 文件替换 / 回退方案的失败日志
- 滑动操作失败 / ADB 输入注入异常
- 中奖截图保存 / OCR 调试输出
- paste_text_at / click 等底层操作的调试输出
- 保留为 stdout:
- 设备选择交互(L220-247,含 input() 提示,需要用户在 stdout 看到)
- _uo_log helper 自身的最终兜底(L73)
回归:146 .py 全量编译通过;underlying_operations 类与 _LOGGER 加载正确;
test_filter_logging / check_web_gui_config_sync 通过。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 12:54:27 +08:00 |
|
 CodexandClaude Opus 4.7
|
4f147d214e
|
P2 §5.3: 4 处单点 importlib.import_module → 静态 from import
把单次调用 douyin_screenshot_manager 的 importlib 改为 from-import:
- douyin/core/douyin_flow_control.py
- douyin/core/underlying_operations.py
- douyin/fudai/core/fudai_debug_utils.py
- douyin/stage/douyin_stage.py
douyin_screenshot_manager 只引用 douyin.core.path_config,与上述 4 个文件
无循环依赖,可以安全静态化。bin/run_cli.py 的 importlib 是有意为之
(绕过 package __init__ 遮蔽),保留。
收益:
- 可读性 + IDE 跳转/类型提示
- 每次调用省去 ~100µs 的 import_module 开销
回归:140 .py 编译通过;4 处 importlib 残留全清;
test_filter_logging / check_web_gui_config_sync 通过;
douyin_screenshot_manager 仍可正常加载。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 12:01:16 +08:00 |
|
 CodexandClaude Opus 4.7
|
d5c9936c88
|
gui_app + base_interface: 内部错误 print → logger
gui/gui_app.py(8 处 sys.stderr print → _LOGGER):
- 配置读取失败、日志文件权限/写入错误(warning/error 级)
- pump_logs 内日志插入失败、循环异常、调度下次更新失败(error/warning 级)
- 顶部 import logging + 模块级 _LOGGER
douyin/core/fudai_modules/base_interface.py(2 处 print → _LOGGER):
- BaseFudaiMixin._safe_log 在主类无 _enhanced_log_kv 时的兜底改为 logger.info
- 顶部 import logging + 模块级 _LOGGER
保留为 stdout 的合理场景:
- bin/run_cli.py 的 [TEST]/[YANGHAO-ONLY] CLI 输出
- bin/manage_logs.py 的 CLI 工具输出
- gui/webgui_launcher.py: GUI 同时把 log 输出到控制台
- douyin/logging/internal_loggers.py: logger 模块自身的初始化失败兜底
- douyin/logging/douyin_logging{,_wrapper}.py: 日志系统内部的格式化输出
回归:140 .py 编译通过;test_filter_logging / check_web_gui_config_sync 通过;
gui.gui_app/web_gui/gui_core/base_interface 全部可加载,_LOGGER 名称正确。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 11:43:44 +08:00 |
|
Codex
|
0131be7869
|
切换 OCR 默认引擎到 PaddleOCR v4-mobile 并简化预处理
- 默认引擎改为 PaddleOCR PP-OCRv4_mobile(实测 369ms/张,比 EasyOCR 629ms 更快且精度大幅提升,coupon 等关键图错字一片 -> 全对)
- EasyOCR 仅作回退,移除"小图自动放大+锐化+对比度增强"预处理(实测对 Paddle 是负优化,会引入伪影/重复字)
- analyse_pic_word 加 LRU 内容哈希缓存(256 条),重复读图直接命中
- analyse_pic_digits 从 200 行重复实现精简成 30 行委托 + 数字过滤
- 统一两处 OCR 初始化为 _build_paddle / _build_easyocr 工厂,消除重复
- 设置 FLAGS_use_mkldnn=false 绕开 Win + Paddle 3.x 的 oneDNN+PIR 不兼容 bug(实测 FLAGS_enable_pir_in_executor=0 也修不掉,关 oneDNN 是当前唯一可行解)
- 决策依据/速度数据/已知问题归档到 docs/ocr_engine_decision.md
- 业务接口完全向后兼容
|
2026-05-21 10:50:30 +08:00 |
|
 CodexandClaude Opus 4.7
|
71f3653354
|
补回上次合并丢失的关键路径修复 + .gitignore 补强 + 依赖版本对齐
上次冲突解决时跳过了 982f57e (P0 清理) 和 b6ae970 (路径修复) 两个 commit,
本提交补回其中影响运行时正确性和文档一致性的 7 处。
E. 路径错位修复
- douyin/core/douyin_fudai.py: _reservations_state_path 与 room_pos_map
状态目录改为优先调用 path_config.get_reservations_path()
- douyin/core/path_config.py: get_reservations_path 注释明确"实际位置 + 写入方"
- gui/components/mapping_utils.py: 删除错误兜底 douyin/state/reservations.json
- gui/components/mapping_table.py: 同步删除 douyin/state/room_pos_map.json 错误兜底
- gui/web_gui.py: get_reservations() 内的兜底由 douyin/state/ 修正为 douyin/core/state/
- bin/run_cli.py: 移除对已删空文件 douyin_reservation_ops.py 的 shim 加载
- douyin/reservation/douyin_reservation_ops.py: 删除 0 字节空文件
F. .gitignore 补强
- 新增 *.bak_* 拦截带日期后缀的备份命名(修复 *.bak 命中失败的场景)
G. 依赖版本对齐
- requirements-minimal.txt: paddleocr/paddlepaddle 改为 >=3.0.0,与 requirements.txt 一致
- README.md: 安装指引中 paddlepaddle==2.5.2 改为 >=3.0.0
回归:全量 .py compileall 通过;7 项断言(path_config 路径、douyin_fudai 切换、
3 处兜底已清、shim 已移除、空文件已删、.gitignore 补强、版本对齐)全部 PASS;
test_filter_logging / check_web_gui_config_sync 通过。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 10:18:17 +08:00 |
|
zzz
|
2e811e71b3
|
Merge branch 'main' into claude/wonderful-brattain-d1cfe0
|
2026-05-21 09:58:24 +08:00 |
|
 CodexandClaude Opus 4.7
|
96f8600d42
|
小批量收尾:删除零引用 scrcpy_screenshot + douyin_fudai/log_viewer print→logger
- 删除 operations/scrcpy_screenshot.py(100 行,仅自身定义自身使用,全仓零外部引用)
- douyin/core/douyin_fudai.py:3 处兜底 print → logging.info/warning(_log_kv 失败时的兜底路径)
- gui/components/log_viewer.py:2 处错误 print → _LOGVIEW_LOGGER.exception(日志线程异常 / 刷新显示异常)
回归:149→148 .py,全量编译通过;test_filter_logging / check_web_gui_config_sync 通过;
fudai_analyse 类正常导出,log_viewer 模块加载 OK。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 09:40:18 +08:00 |
|
 CodexandClaude Opus 4.5
|
2d6cbecf7e
|
refactor: 抽取 underlying_operations 顶部辅助函数到 io_utils.py
将 4 个模块级辅助函数及相关常量从 underlying_operations.py 抽离到
新建的 douyin/core/io_utils.py:
- _verify_png_integrity
- _safe_replace_file
- _ensure_parent_dir
- _mirror_screenshot_to_external
- _EXTERNAL_DOUYIN_FUDAI_DIR / _EXTERNAL_AXF_SCREENSHOT
underlying_operations.py 仍重新导出这些符号,保持向后兼容,
所有外部 import 无需修改。
文件行数:3508 -> 3342(减 166 行)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 09:01:14 +08:00 |
|
 CodexandClaude Opus 4.5
|
8fe7ff0585
|
refactor: 根目录核心模块迁移到 douyin/core/ 和 douyin/logging/
将 4 个根目录核心模块迁移到合理位置:
- path_config.py -> douyin/core/path_config.py
- version.py -> douyin/core/version.py
- Underlying_Operations.py -> douyin/core/underlying_operations.py
- unified_logger.py -> douyin/logging/unified_logger.py
配套更新所有 import:
- path_config: 41 处 import 改为 douyin.core.path_config
- version: 4 处改为 douyin.core.version
- unified_logger: 5 处改为 douyin.logging.unified_logger
- Underlying_Operations: 14 处改为 douyin.core.underlying_operations
修复 path_config.PROJECT_ROOT 计算(向上 2 级而非当前目录)。
验证:python -m compileall 全项目通过。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 00:23:14 +08:00 |
|
 CodexandClaude Opus 4.5
|
92718a7cb4
|
fix: douyin_fudai 关键路径异常添加日志
- run_id 生成失败时记录 logging.debug
- 日志系统初始化失败时记录 logging.warning,便于排查
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-20 23:03:27 +08:00 |
|
 CodexandClaude Opus 4.5
|
ff8de2c9b8
|
fix: 修复7个Critical并发安全和异常处理问题
1. OCR 单例无锁保护 - 添加 _ocr_lock 和 _ocr_coords_lock
2. ADB 文本广播命令注入 - 使用 shlex.quote() 转义
3. 截图文件 Race Condition - 添加 PNG 完整性验证
4. JSON 持久化无锁 - 添加文件级锁字典
5. 双检查锁不完整 - 修复 _ensure_debug_save_worker_started
6. Daemon 线程无 Graceful Shutdown - 添加 shutdown event 和 atexit
7. 关键路径异常处理 - 添加 logging.debug 替代 pass
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-20 22:25:35 +08:00 |
|
Codex
|
e7a7d3f888
|
Fix device selection and adb command safety
|
2026-05-20 18:43:58 +08:00 |
|