From da272de7f8a3bfd3fbb0d11eb1196173d31ce27c Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 9 Jan 2026 20:20:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=90=88=E5=B9=B6ADB=20subprocess?= =?UTF-8?q?=E5=92=8C=E6=88=AA=E5=9B=BE=E4=BF=A1=E6=81=AF=E5=88=B0=E5=8D=95?= =?UTF-8?q?=E4=B8=AA=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA=EF=BC=9B=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=AB=98=E4=BB=B7=E5=80=BC=E6=88=BF=E9=97=B4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=92=8C=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Underlying_Operations.py | 17 +- config/config.json | 4 +- douyin/detection/douyin_pixel.py | 4 +- douyin/stage/douyin_stage.py | 21 --- state/high_value_rooms.json | 287 +++++++++++++++++++++++++------ 5 files changed, 244 insertions(+), 89 deletions(-) diff --git a/Underlying_Operations.py b/Underlying_Operations.py index fb8e7a0..ccc8d97 100644 --- a/Underlying_Operations.py +++ b/Underlying_Operations.py @@ -840,11 +840,7 @@ class underlying_operations: ) adb_subprocess_dur = (time_module.time() - adb_start) * 1000.0 - logging.info( - "[截图] ADB exec-out subprocess耗时(ms)=%.1f attempt=%d", - adb_subprocess_dur, - attempt + 1, - ) + # 合并ADB subprocess耗时到最终汇总日志中,不单独输出 # 优化:移除 fsync(现代文件系统会自动同步,减少不必要的磁盘I/O) # 文件写入已经完成,操作系统会在适当时机同步到磁盘 @@ -910,9 +906,9 @@ class underlying_operations: overall_dur = ( time_module.time() - overall_start ) * 1000.0 - # 记录分阶段耗时汇总,便于排查瓶颈(JSON-like) + # 合并所有截图信息到单个日志输出 logging.info( - "[截图] 总耗时(ms)=%.1f (exec-out成功) | 汇总: cleanup=%.1f adb_execout=%.1f validate_tmp=%.1f replace=%.1f mirror=%.1f validate_out=%.1f", + "[截图] ✓ 获取屏幕截图成功 | 总耗时(ms)=%.1f (exec-out成功) | 汇总: cleanup=%.1f adb_execout=%.1f validate_tmp=%.1f replace=%.1f mirror=%.1f validate_out=%.1f", overall_dur, cleanup_dur, adb_subprocess_dur, @@ -921,9 +917,6 @@ class underlying_operations: mirror_dur, validate_out_dur, ) - print( - f"[{timetag}] [截图] ✓ 获取屏幕截图成功" - ) return True except Exception: pass @@ -1055,12 +1048,12 @@ class underlying_operations: fallback_total_dur = ( time_module.time() - fallback_start ) * 1000.0 + # 合并回退方案成功信息到单个日志输出 logging.info( - "[截图] _get_screenshot_direct总耗时(ms)=%.1f (回退方案成功, 回退部分耗时=%.1fms)", + "[截图] ✓ 获取屏幕截图成功 | 总耗时(ms)=%.1f (回退方案成功, 回退部分耗时=%.1fms)", overall_dur, fallback_total_dur, ) - print("{} 获取屏幕截图".format(timetag)) return True except Exception: pass diff --git a/config/config.json b/config/config.json index 48fb46a..25dc1e9 100644 --- a/config/config.json +++ b/config/config.json @@ -7,7 +7,7 @@ "max_participants": 0, "skip_if_countdown_gt_seconds": 120, "reset_after_swipes_enabled": true, - "reset_after_swipes": 10, + "reset_after_swipes": 20, "reset_after_swipes_action": "back", "auto_join_fansclub": true, "fansclub_fail_action": "switch", @@ -31,7 +31,7 @@ "fudai_icon_max_wait_seconds": 5.0, "fudai_icon_retry_delay_seconds": 0.1, "fudai_exit_after_misses": 10, - "enable_back_on_misses": true, + "enable_back_on_misses": false, "fudai_click_wait_seconds": 1.6, "fudai_detail_initial_wait_seconds": 0.8, "fudai_detail_verified_wait_seconds": 0.2, diff --git a/douyin/detection/douyin_pixel.py b/douyin/detection/douyin_pixel.py index d9bb63b..a683461 100644 --- a/douyin/detection/douyin_pixel.py +++ b/douyin/detection/douyin_pixel.py @@ -254,7 +254,9 @@ def detect_redpacket_popup_background( result = red_ratio > 0.15 if return_info: - reason_value: Optional[str] = None if result else "red_ratio_below_threshold" + reason_value: Optional[str] = ( + None if result else "red_ratio_below_threshold" + ) return result, { "method": "pixel_detection", "red_ratio": float(red_ratio), diff --git a/douyin/stage/douyin_stage.py b/douyin/stage/douyin_stage.py index 77efa5c..be080e8 100644 --- a/douyin/stage/douyin_stage.py +++ b/douyin/stage/douyin_stage.py @@ -704,27 +704,6 @@ def diagnose_stage_from_current_screen(analyser): # type: ignore[misc] # noqa: step15_elapsed = (time.time() - step_redpacket_start) * 1000 _log("步骤1.5[检测购物红包弹窗]-完成", 总耗时毫秒=step15_elapsed) - # 优先级2:优惠券弹窗检测(使用参与按钮区域,检测"开心收下") - # 优惠券弹窗和参与福袋按钮在同一个位置,需要通过OCR区分 - # ========== 步骤2:OCR检测(已暂时禁用)========== - step2_start = time.time() - # 注意:优惠券弹窗和按钮类型区分的OCR检测区域相同 (200, 1940)-(880, 2140) - # 为避免重复OCR,已暂时禁用这两个OCR检测步骤 - # 阶段判断将依赖像素检测和任务数量检测等其他方式 - has_red_button_area = pixel_state.get( - "has_attend_button_red", False - ) or pixel_state.get("has_fansclub_join_red", False) - if has_red_button_area: - _log( - "步骤2[OCR检测]-已禁用", - 说明="OCR检测已暂时禁用,跳过优惠券弹窗和按钮类型区分检测", - ) - # OCR检测已禁用,继续后续检测 - - # 步骤2结束计时 - step2_elapsed = (time.time() - step2_start) * 1000 - _log("步骤2[OCR检测]-完成", 总耗时毫秒=step2_elapsed) - # ========== 步骤1:像素检测福袋详情页(从并行检测结果获取)========== step1_fudai_start = time.time() # 从并行检测结果中获取福袋详情页检测结果(任务数量检测) diff --git a/state/high_value_rooms.json b/state/high_value_rooms.json index cc570aa..dd7fea2 100644 --- a/state/high_value_rooms.json +++ b/state/high_value_rooms.json @@ -1,7 +1,7 @@ { - "updated_ts": 1767947558.7674894, + "updated_ts": 1767961153.6681945, "reason": "reservation", - "total": 148, + "total": 159, "rooms": [ { "first_seen_ts": 1765799932.458368, @@ -548,10 +548,10 @@ }, { "first_seen_ts": 1765736209.4437785, - "last_seen_ts": 1767946638.6337235, - "seen_count": 78, - "pos_seen": 8, - "pos_updated_ts": 1767946638.6337235, + "last_seen_ts": 1767960515.2195117, + "seen_count": 99, + "pos_seen": 9, + "pos_updated_ts": 1767960515.2195117, "room_title_raw_last": "梵象名品", "alias_raw": [ "梵象名品...", @@ -1598,10 +1598,10 @@ }, { "first_seen_ts": 1767853185.2990494, - "last_seen_ts": 1767947558.7674894, - "seen_count": 52, - "pos_seen": 5, - "pos_updated_ts": 1767947558.7674894, + "last_seen_ts": 1767960616.7397337, + "seen_count": 65, + "pos_seen": 13, + "pos_updated_ts": 1767960616.7397337, "room_title_raw_last": "作业帮数", "alias_raw": [ "作业帮数" @@ -1647,10 +1647,10 @@ }, { "first_seen_ts": 1767856135.4817257, - "last_seen_ts": 1767947109.1286912, - "seen_count": 39, - "pos_seen": 9, - "pos_updated_ts": 1767947109.1286912, + "last_seen_ts": 1767960490.7711394, + "seen_count": 58, + "pos_seen": 8, + "pos_updated_ts": 1767960490.7711394, "room_title_raw_last": "六号折扣", "alias_raw": [ "六号折扣" @@ -1808,13 +1808,15 @@ }, { "first_seen_ts": 1767863279.932139, - "last_seen_ts": 1767871705.4416816, - "seen_count": 22, - "pos_seen": 8, - "pos_updated_ts": 1767871705.4416816, - "room_title_raw_last": "汀南紫砂", + "last_seen_ts": 1767960719.8836527, + "seen_count": 37, + "pos_seen": 17, + "pos_updated_ts": 1767960719.8836527, + "room_title_raw_last": "汀南紫砂。", "alias_raw": [ - "汀南紫砂" + "汀南紫砂", + "汀南紫砂。。", + "汀南紫砂。" ], "key_kind": "norm", "last_content": "", @@ -1840,18 +1842,19 @@ }, { "first_seen_ts": 1767863974.4459054, - "last_seen_ts": 1767947508.7664201, - "seen_count": 47, - "pos_seen": 3, - "pos_updated_ts": 1767947508.7664201, - "room_title_raw_last": "交个朋友。", + "last_seen_ts": 1767961153.6681945, + "seen_count": 64, + "pos_seen": 15, + "pos_updated_ts": 1767961153.6681945, + "room_title_raw_last": "交个朋友。。", "alias_raw": [ "交个朋友", - "交个朋友。" + "交个朋友。", + "交个朋友。。" ], "key_kind": "norm", "last_content": "", - "last_prize_value_yuan": 699.0, + "last_prize_value_yuan": 1199.0, "max_prize_value_yuan": 1199.0, "room_title": "交个朋友" }, @@ -1938,10 +1941,10 @@ }, { "first_seen_ts": 1767873528.6011586, - "last_seen_ts": 1767873776.7842386, - "seen_count": 2, - "pos_seen": 5, - "pos_updated_ts": 1767873776.7842386, + "last_seen_ts": 1767959867.380778, + "seen_count": 3, + "pos_seen": 18, + "pos_updated_ts": 1767959867.380778, "room_title_raw_last": "户外发", "alias_raw": [ "户外发" @@ -1954,10 +1957,10 @@ }, { "first_seen_ts": 1767873899.5342953, - "last_seen_ts": 1767946819.3613539, - "seen_count": 2, - "pos_seen": 3, - "pos_updated_ts": 1767946819.3613539, + "last_seen_ts": 1767959618.0057049, + "seen_count": 23, + "pos_seen": 11, + "pos_updated_ts": 1767959618.0057049, "room_title_raw_last": "Entertain", "alias_raw": [ "Entertain_", @@ -2340,10 +2343,10 @@ }, { "first_seen_ts": 1767924514.7214658, - "last_seen_ts": 1767947147.5061107, - "seen_count": 8, - "pos_seen": 1, - "pos_updated_ts": 1767947147.5061107, + "last_seen_ts": 1767950579.828834, + "seen_count": 13, + "pos_seen": 2, + "pos_updated_ts": 1767950579.828834, "room_title_raw_last": "演员朱泳", "alias_raw": [ "演员朱泳。", @@ -2358,10 +2361,10 @@ }, { "first_seen_ts": 1767924845.0501997, - "last_seen_ts": 1767944804.93843, - "seen_count": 18, - "pos_seen": 4, - "pos_updated_ts": 1767944804.93843, + "last_seen_ts": 1767958269.8038957, + "seen_count": 29, + "pos_seen": 8, + "pos_updated_ts": 1767958269.8038957, "room_title_raw_last": "作业帮教", "alias_raw": [ "作业帮教" @@ -2407,13 +2410,14 @@ }, { "first_seen_ts": 1767927142.7995243, - "last_seen_ts": 1767927142.7995243, - "seen_count": 1, - "pos_seen": 0, - "pos_updated_ts": 1767927142.7995243, - "room_title_raw_last": "九乐宦方", + "last_seen_ts": 1767959780.7275472, + "seen_count": 8, + "pos_seen": 8, + "pos_updated_ts": 1767959780.7275472, + "room_title_raw_last": "九乐宦方。。", "alias_raw": [ - "九乐宦方" + "九乐宦方", + "九乐宦方。。" ], "key_kind": "norm", "last_content": "", @@ -2471,10 +2475,10 @@ }, { "first_seen_ts": 1767939973.9032884, - "last_seen_ts": 1767944995.7188, - "seen_count": 5, - "pos_seen": 7, - "pos_updated_ts": 1767944995.7188, + "last_seen_ts": 1767960919.8588204, + "seen_count": 11, + "pos_seen": 11, + "pos_updated_ts": 1767960919.8588204, "room_title_raw_last": "交个朋友00", "alias_raw": [ "交个朋友00" @@ -2532,6 +2536,183 @@ "last_prize_value_yuan": 1199.0, "max_prize_value_yuan": 1199.0, "room_title": "孙钛" + }, + { + "first_seen_ts": 1767948447.237501, + "last_seen_ts": 1767948447.237501, + "seen_count": 1, + "pos_seen": 0, + "pos_updated_ts": 1767948447.237501, + "room_title_raw_last": "演员失泳。", + "alias_raw": [ + "演员失泳。" + ], + "key_kind": "norm", + "last_content": "", + "last_prize_value_yuan": 11299.0, + "max_prize_value_yuan": 11299.0, + "room_title": "演员失泳" + }, + { + "first_seen_ts": 1767952399.767971, + "last_seen_ts": 1767952399.767971, + "seen_count": 1, + "pos_seen": 10, + "pos_updated_ts": 1767952399.767971, + "room_title_raw_last": "苏苏定制", + "alias_raw": [ + "苏苏定制" + ], + "key_kind": "norm", + "last_content": "", + "last_prize_value_yuan": 2999.0, + "max_prize_value_yuan": 2999.0, + "room_title": "苏苏定制" + }, + { + "first_seen_ts": 1767952617.613551, + "last_seen_ts": 1767952617.613551, + "seen_count": 1, + "pos_seen": 19, + "pos_updated_ts": 1767952617.613551, + "room_title_raw_last": "万小姐珠宝", + "alias_raw": [ + "万小姐珠宝" + ], + "key_kind": "norm", + "last_content": "", + "last_prize_value_yuan": 1799.0, + "max_prize_value_yuan": 1799.0, + "room_title": "万小姐珠宝" + }, + { + "first_seen_ts": 1767953493.6921928, + "last_seen_ts": 1767959564.6585362, + "seen_count": 26, + "pos_seen": 9, + "pos_updated_ts": 1767959564.6585362, + "room_title_raw_last": "头baby-", + "alias_raw": [ + "头baby-" + ], + "key_kind": "norm", + "last_content": "", + "last_prize_value_yuan": 999.0, + "max_prize_value_yuan": 999.0, + "room_title": "头baby" + }, + { + "first_seen_ts": 1767956181.6614752, + "last_seen_ts": 1767960040.6180284, + "seen_count": 2, + "pos_seen": 18, + "pos_updated_ts": 1767960040.6180284, + "room_title_raw_last": "江南紫砂", + "alias_raw": [ + "江南紫砂" + ], + "key_kind": "norm", + "last_content": "", + "last_prize_value_yuan": 666.0, + "max_prize_value_yuan": 666.0, + "room_title": "江南紫砂" + }, + { + "first_seen_ts": 1767956526.9128833, + "last_seen_ts": 1767958316.635666, + "seen_count": 2, + "pos_seen": 10, + "pos_updated_ts": 1767958316.635666, + "room_title_raw_last": "云南冰岛", + "alias_raw": [ + "云南冰岛" + ], + "key_kind": "norm", + "last_content": "", + "last_prize_value_yuan": 1199.0, + "max_prize_value_yuan": 1199.0, + "room_title": "云南冰岛" + }, + { + "first_seen_ts": 1767956593.8674803, + "last_seen_ts": 1767960646.2858467, + "seen_count": 11, + "pos_seen": 14, + "pos_updated_ts": 1767960646.2858467, + "room_title_raw_last": "李亚鹏9.1", + "alias_raw": [ + "李亚鹏9.1" + ], + "key_kind": "norm", + "last_content": "", + "last_prize_value_yuan": 1999.0, + "max_prize_value_yuan": 1999.0, + "room_title": "李亚鹏91" + }, + { + "first_seen_ts": 1767958139.4660323, + "last_seen_ts": 1767958139.4660323, + "seen_count": 1, + "pos_seen": 6, + "pos_updated_ts": 1767958139.4660323, + "room_title_raw_last": "头babv-", + "alias_raw": [ + "头babv-" + ], + "key_kind": "norm", + "last_content": "", + "last_prize_value_yuan": 999.0, + "max_prize_value_yuan": 999.0, + "room_title": "头babv" + }, + { + "first_seen_ts": 1767959442.9244063, + "last_seen_ts": 1767960987.4201305, + "seen_count": 2, + "pos_seen": 19, + "pos_updated_ts": 1767960987.4201305, + "room_title_raw_last": "交介朋友。", + "alias_raw": [ + "交介朋友", + "交介朋友。" + ], + "key_kind": "norm", + "last_content": "", + "last_prize_value_yuan": 1199.0, + "max_prize_value_yuan": 1199.0, + "room_title": "交介朋友" + }, + { + "first_seen_ts": 1767960559.2890444, + "last_seen_ts": 1767960559.2890444, + "seen_count": 1, + "pos_seen": 11, + "pos_updated_ts": 1767960559.2890444, + "room_title_raw_last": "东方甄选", + "alias_raw": [ + "东方甄选" + ], + "key_kind": "norm", + "last_content": "", + "last_prize_value_yuan": 899.0, + "max_prize_value_yuan": 899.0, + "room_title": "东方甄选" + }, + { + "first_seen_ts": 1767960671.9654737, + "last_seen_ts": 1767960671.9654737, + "seen_count": 1, + "pos_seen": 15, + "pos_updated_ts": 1767960671.9654737, + "room_title_raw_last": "丰源百货仓", + "alias_raw": [ + "丰源百货仓" + ], + "key_kind": "norm", + "last_content": "", + "last_prize_value_yuan": 1999.0, + "max_prize_value_yuan": 1999.0, + "room_title": "丰源百货仓" } ] } \ No newline at end of file