From 361dc973e706c15f0a1b6d09c59da89302753d5a Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 16 Jan 2026 16:16:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=87=E6=8D=A2=E7=9B=B4=E6=92=AD?= =?UTF-8?q?=E9=97=B4=E5=89=8D=E6=A3=80=E6=9F=A5=E6=98=A0=E5=B0=84=E8=A1=A8?= =?UTF-8?q?=E5=B9=B6=E8=AE=B0=E5=BD=95=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在切换直播间前检查当前直播间是否已记录映射表 - 如果没有记录,直接识别截图并记录直播间标题 - 修复预约验证中截图复用问题,改为直接强制截图覆盖 --- .../reservation/douyin_reservation_handler.py | 17 ++++++++++------- douyin/reservation/douyin_reservation_verify.py | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/douyin/reservation/douyin_reservation_handler.py b/douyin/reservation/douyin_reservation_handler.py index 8091f33..411e41f 100644 --- a/douyin/reservation/douyin_reservation_handler.py +++ b/douyin/reservation/douyin_reservation_handler.py @@ -277,7 +277,9 @@ class ReservationHandler: "预约", "[预约] 准备记录映射表", room_pos=room_pos, - room_title=getattr(analyser, "current_room_title", ""), # 当前缓存的标题 + room_title=getattr( + analyser, "current_room_title", "" + ), # 当前缓存的标题 has_fudai=has_fudai, fudai_content=fudai_content[:30] if fudai_content else "", current_map_size=len( @@ -313,21 +315,22 @@ class ReservationHandler: # 映射表中没有记录,需要直接识别截图记录直播间标题 try: from douyin.fudai import douyin_fudai_detail + y_pianyi_val = int(getattr(analyser, "y_pianyi", 0) or 0) room_title, room_title_raw = ( douyin_fudai_detail.read_live_room_title_core( analyser, y_pianyi_val ) ) - + # 更新 analyser 的属性 analyser.current_room_title = room_title analyser.current_room_title_raw = room_title_raw - + # 标记该位置已识别过标题 identified_positions.add(room_pos) analyser._room_title_identified_positions = identified_positions - + analyser._log_kv( # type: ignore[attr-defined] "预约", "[预约] 识别并记录直播间标题到映射表", @@ -336,11 +339,11 @@ class ReservationHandler: room_title=room_title, room_title_raw=room_title_raw, ) - + # 更新房间信息 room_info["title"] = room_title room_info["title_raw"] = room_title_raw - + except Exception as e: analyser._log_kv( # type: ignore[attr-defined] "预约", @@ -349,7 +352,7 @@ class ReservationHandler: room_pos=room_pos, level="WARNING", ) - + analyser._room_pos_to_title_map[room_pos] = room_info try: analyser._log_kv( # type: ignore[attr-defined] diff --git a/douyin/reservation/douyin_reservation_verify.py b/douyin/reservation/douyin_reservation_verify.py index c87e0bf..5bb6fd7 100644 --- a/douyin/reservation/douyin_reservation_verify.py +++ b/douyin/reservation/douyin_reservation_verify.py @@ -388,7 +388,7 @@ def validate_back_to_reservation( analyser.current_room_title = "" analyser.current_room_title_raw = "" analyser._screenshot_ready_for_ocr = False - + # 直接强制截图覆盖,确保获取当前直播间的最新截图 try: analyser.operation.get_screenshot(analyser.device_id)