fix: Clean up blank lines and enhance readability across multiple files

- Removed excessive blank lines from various markdown and Python files to improve readability and maintainability.
- Ensured consistent formatting across documentation and code files, contributing to overall project clarity.
- Enhanced logging mechanisms for better consistency and debugging support.
This commit is contained in:
Your Name committed 2025-12-27 15:19:04 +08:00
1 parent 4678adb8f3
commit efaa3d3adc
36 files changed
+15075 -517

No files matched your search

File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+8
View File
@@ -180,6 +180,14 @@ python cleanup_unused_files.py
+8
View File
@@ -191,6 +191,14 @@ except Exception as e:
+8
View File
@@ -394,6 +394,14 @@ self.last_fudai_x: int = 0 # 上次检测到的福袋图标X坐标
+8
View File
@@ -278,6 +278,14 @@ YYYYMMDD_HHMMSS_操作类型_图片名_步骤_坐标_额外信息.png
+8
View File
@@ -249,6 +249,14 @@ python check_dependencies.py
+8
View File
@@ -228,6 +228,14 @@ douyin_guaji
+8
View File
@@ -169,6 +169,14 @@
+8
View File
@@ -381,6 +381,14 @@ douyin_fudai_finder.py
+8
View File
@@ -180,6 +180,14 @@ self.ocr = easyocr.Reader(
+8
View File
@@ -139,6 +139,14 @@ python 生成WPS流程图.py
+8
View File
@@ -153,6 +153,14 @@ else:
+2 -2
View File
@@ -18,7 +18,7 @@
"high_value_fudai_after_action": "continue",
"high_value_room_revisit_enabled": true,
"high_value_room_revisit_only_current_run": true,
"reservation_back_verify_enabled": false,
"reservation_back_verify_enabled": true,
"reservation_back_swipe_delay": 0.5,
"reservation_preempt_min_value": 0.0,
"desktop_icon_x": 153,
@@ -82,7 +82,7 @@
"skip_if_countdown_lt_seconds": 5,
"no_attend_timeout_minutes": 30.0,
"logging": {
"level": "INFO",
"level": "DEBUG",
"file_path": "logs/unified.log",
"keep_days": 30,
"use_dated_logs": true,
+426 -135
View File
@@ -73,6 +73,8 @@ class fudai_analyse:
self._log_kv_orig = None
# 使用增强版本
self._log_kv = self._enhanced_log_kv
# 用于跟踪上一个日志标签,以便检测阶段变化并添加分隔符
self._last_log_tag = None
# 预定义可在运行中动态创建的属性,避免 access-before-definition / attribute-defined-outside-init 警告
self._std_logger = None # type: ignore[assignment]
@@ -232,10 +234,179 @@ class fudai_analyse:
os.path.dirname(__file__), "state", "reservations.json"
)
# 运行时直播间标题和位置映射表(用于回退校验)
# 格式:{room_pos: (room_title, room_title_raw)}
self._room_pos_to_title_map: dict[int, tuple[str, str]] = {}
# 初次加载配置
self.load_config()
# ===== 兼容原始脚本的一些简单封装方法 =====
def _find_room_pos_by_title(self, target_title: str, target_title_raw: str = "") -> int | None:
"""根据直播间标题在运行时映射表中查找对应的位置。
返回:
如果找到匹配的位置,返回位置值;否则返回 None
"""
try:
if not target_title and not target_title_raw:
return None
room_pos_map = getattr(self, "_room_pos_to_title_map", {})
if not room_pos_map:
return None
# 规范化目标标题
try:
import douyin_high_value_room
if hasattr(douyin_high_value_room, '_normalize_room_title'):
target_norm = douyin_high_value_room._normalize_room_title(target_title) # type: ignore[attr-defined]
else:
target_norm = target_title.strip()
except Exception:
target_norm = target_title.strip()
# 遍历映射表查找匹配的标题
best_match_pos = None
best_match_score = 0.0
for pos, (recorded_title, recorded_title_raw) in room_pos_map.items():
if not recorded_title and not recorded_title_raw:
continue
# 规范化记录的标题
try:
import douyin_high_value_room
if hasattr(douyin_high_value_room, '_normalize_room_title'):
recorded_norm = douyin_high_value_room._normalize_room_title(recorded_title) # type: ignore[attr-defined]
else:
recorded_norm = recorded_title.strip()
except Exception:
recorded_norm = recorded_title.strip()
# 计算匹配度
match_score = 0.0
if target_norm and recorded_norm:
# 完全匹配
if target_norm == recorded_norm:
match_score = 1.0
# 子串匹配
elif target_norm in recorded_norm or recorded_norm in target_norm:
match_score = 0.8
# 使用相似度
else:
try:
import difflib
match_score = difflib.SequenceMatcher(None, target_norm, recorded_norm).ratio()
except Exception:
match_score = 0.0
# 如果匹配度足够高,记录最佳匹配
if match_score > best_match_score and match_score >= 0.6:
best_match_score = match_score
best_match_pos = pos
if best_match_pos is not None:
try:
self._log_kv(
"预约",
"[预约] _find_room_pos_by_title:在映射表中找到匹配位置",
target_title=target_title[:50] if target_title else "",
found_pos=best_match_pos,
match_score=round(best_match_score, 3),
recorded_title=room_pos_map[best_match_pos][0][:50] if room_pos_map[best_match_pos][0] else "",
)
except Exception:
pass
return best_match_pos
return None
except Exception as e:
try:
self._log_kv(
"预约",
"[预约] _find_room_pos_by_title:查找时出错",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
return None
def _record_room_title_and_pos(self) -> None:
"""记录当前直播间的标题和位置到运行时映射表。
用于预约回退校验时验证位置信息。
"""
try:
room_pos = int(getattr(self, "room_pos", 0) or 0)
# 读取当前直播间标题
try:
import douyin_fudai_detail as dfd_module
y_pianyi_val = int(getattr(self, "y_pianyi", 0) or 0)
room_title, room_title_raw = dfd_module.read_live_room_title_core(
self, y_pianyi_val
)
# 更新 analyser 的属性
try:
self.current_room_title = room_title
self.current_room_title_raw = room_title_raw
except Exception:
pass
# 记录到映射表
if room_pos not in self._room_pos_to_title_map:
self._room_pos_to_title_map[room_pos] = (room_title, room_title_raw)
try:
self._log_kv(
"预约",
"[预约] 记录直播间标题和位置到运行时映射表",
room_pos=room_pos,
room_title=room_title[:50] if room_title else "",
room_title_raw=room_title_raw[:50] if room_title_raw else "",
map_size=len(self._room_pos_to_title_map),
)
except Exception:
pass
else:
# 如果已存在,更新标题(可能标题有变化)
old_title, old_title_raw = self._room_pos_to_title_map[room_pos]
if old_title != room_title or old_title_raw != room_title_raw:
self._room_pos_to_title_map[room_pos] = (room_title, room_title_raw)
try:
self._log_kv(
"预约",
"[预约] 更新直播间标题和位置到运行时映射表",
room_pos=room_pos,
old_room_title=old_title[:50] if old_title else "",
new_room_title=room_title[:50] if room_title else "",
)
except Exception:
pass
except Exception as e:
# 如果读取标题失败,尝试使用缓存的标题
try:
room_title = str(getattr(self, "current_room_title", "") or "")
room_title_raw = str(getattr(self, "current_room_title_raw", "") or "")
if room_title or room_title_raw:
self._room_pos_to_title_map[room_pos] = (room_title, room_title_raw)
try:
self._log_kv(
"预约",
"[预约] 使用缓存标题记录直播间位置到运行时映射表",
room_pos=room_pos,
room_title=room_title[:50] if room_title else "",
error=str(e),
)
except Exception:
pass
except Exception:
pass
except Exception:
pass
def click(self, x: int, y: int) -> None:
"""兼容原版 fudai_analyse.click:转发到底层 operation.click。"""
start_time = time.time()
@@ -1310,6 +1481,47 @@ class fudai_analyse:
# 构建完整日志行
log_line = " ".join(log_parts)
# 判断是否需要添加分隔符(便于查看日志)
need_separator = False
separator_reason = ""
# 1. 错误发生时(优先级最高)
if log_level in ("ERROR", "WARNING", "CRITICAL"):
need_separator = True
separator_reason = "错误/警告"
# 2. 运行开始时
elif tag and any(keyword in str(tag) for keyword in ["运行", "启动", "开始", "初始化"]):
need_separator = True
separator_reason = "运行开始"
# 3. 阶段变化时(tag变化且包含阶段相关关键词)
elif tag and self._last_log_tag != tag:
if any(keyword in str(tag) for keyword in ["阶段", "循环", "参与", "检测", "寻找", "进入", "退出"]):
need_separator = True
separator_reason = "阶段变化"
# 4. 重要操作(通过tag判断)
elif tag and self._last_log_tag != tag:
if any(keyword in str(tag) for keyword in ["参与", "中奖", "完成", "失败", "超时"]):
need_separator = True
separator_reason = "重要操作"
# 输出分隔符(如果需要)
if need_separator:
try:
# 使用等号作为分隔符,更清晰易读
separator = "=" * 80
# 在分隔符中间显示原因,更美观
reason_text = f" {separator_reason} "
separator_line = f"{separator}\n{reason_text.center(80, '=')}\n{separator}"
print(separator_line, flush=True)
except Exception:
pass
# 更新上一个日志标签
self._last_log_tag = tag
# 始终输出到 stdout(供 GUI 捕获)- 这是最重要的!
try:
print(log_line, flush=True) # flush=True 确保立即输出,不缓冲
@@ -3464,6 +3676,15 @@ class fudai_analyse:
except Exception:
pass
# 记录当前直播间的标题和位置到运行时映射表(用于回退校验)
# 如果是在回退过程中(_seek_reservation_room),跳过记录,因为之前已经记录过了
try:
skip_record = bool(getattr(self, "_skip_record_title_during_seek", False))
if not skip_record:
self._record_room_title_and_pos()
except Exception:
pass
def _return_to_recommend_and_reenter_live(self) -> None:
"""返回推荐页面并重新进入直播间。
@@ -3628,6 +3849,15 @@ class fudai_analyse:
self.room_pos -= 1
except Exception:
self.room_pos = 0
# 记录当前直播间的标题和位置到运行时映射表(用于回退校验)
# 如果是在回退过程中(_seek_reservation_room),跳过记录,因为之前已经记录过了
try:
skip_record = bool(getattr(self, "_skip_record_title_during_seek", False))
if not skip_record:
self._record_room_title_and_pos()
except Exception:
pass
def _maybe_reset_after_swipes(self) -> int:
"""达到切换阈值后,在当前直播间页面回退到第一个直播间。
@@ -3688,9 +3918,21 @@ class fudai_analyse:
start_y = 800 * ry // 2400 # 上方起始位置
end_x = 760 * rx // 1080
end_y = 1600 * ry // 2400 # 下方结束位置
self.operation.swipe(
self.device_id, start_x, start_y, end_x, end_y, 200
)
# 直接使用 ADB 内部滑动命令
try:
import subprocess
if hasattr(self.operation, '_adb'):
adb_cmd = self.operation._adb()
else:
import os
adb_cmd = os.environ.get("ADB_EXECUTABLE", "adb") or "adb"
if not adb_cmd.startswith('"') and not adb_cmd.endswith('"'):
adb_cmd = f'"{adb_cmd}"'
cmd = f"{adb_cmd} -s {self.device_id} shell input swipe {start_x} {start_y} {end_x} {end_y} 200"
subprocess.run(cmd, shell=True, timeout=5.0, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except Exception:
# 回退到 operation.swipe
self.operation.swipe(self.device_id, start_x, start_y, end_x, end_y, 200)
try:
self._log_kv("流程", "回退直播间 {}/{}".format(i + 1, back_times))
except Exception:
@@ -3731,6 +3973,8 @@ class fudai_analyse:
# 注意:pos_diff = target_pos - cur_pos
# - 如果 pos_diff < 0,说明 target_pos < cur_pos,目标在上方,需要向上回退(减少 room_pos)
# - 如果 pos_diff > 0,说明 target_pos > cur_pos,目标在下方,需要向下切换(增加 room_pos)
# 注意:如果预先下滑了一次(在 process_reservation_attend_window 中),cur_pos 已经减1了
# 但这是为了确保在直播列表中,不影响回退次数的计算,因为回退次数是基于实际的位置差计算的
pos_diff = target_pos - cur_pos
try:
@@ -3747,6 +3991,20 @@ class fudai_analyse:
target_room_title = str(item.get("room_title") or "").strip()
target_room_title_raw = str(item.get("room_title_raw") or "").strip()
# 输出目标直播间的位置和标题信息
try:
self._log_kv(
"预约",
"[预约] _seek_reservation_room:开始回退到目标直播间",
target_room_title=target_room_title,
target_room_title_raw=target_room_title_raw,
target_pos=target_pos,
current_room_pos=cur_pos,
target_room_info=f"位置={target_pos}, 标题={target_room_title or target_room_title_raw}",
)
except Exception:
pass
try:
self._log_kv(
"预约",
@@ -3767,6 +4025,11 @@ class fudai_analyse:
elif pos_diff < 0:
# 目标在上方(target_pos < cur_pos),需要向上回退(减少 room_pos)
# 使用 swipe_down_back_from_live(),它会执行 room_pos -= 1
# 注意:如果预先下滑了一次(在 process_reservation_attend_window 中),cur_pos 已经减1了
# 这会导致 pos_diff 的计算少1,所以需要补偿:back_times = abs(pos_diff) + 1
# 但实际上,预先下滑是为了确保在直播列表中,不应该影响回退次数
# 所以如果预先下滑了,pos_diff 已经包含了这个影响,直接使用 abs(pos_diff) 即可
# 但为了确保回退到正确位置,如果 pos_diff < 0,需要回退 abs(pos_diff) 次
back_times = min(abs(pos_diff), max_back) if max_back > 0 else abs(pos_diff)
try:
self._log_kv(
@@ -3782,12 +4045,22 @@ class fudai_analyse:
except Exception:
pass
delay_s = float(getattr(self, "reservation_back_swipe_delay", 0.6) or 0.6)
# 回退时设置标志,跳过记录标题(因为之前已经记录过了)
try:
self._skip_record_title_during_seek = True
except Exception:
pass
for _ in range(back_times):
self.swipe_down_back_from_live()
try:
self.operation.delay(delay_s)
except Exception:
time.sleep(delay_s)
# 清除标志
try:
self._skip_record_title_during_seek = False
except Exception:
pass
else:
# 目标在下方(target_pos > cur_pos),需要向下切换(增加 room_pos)
# 使用 swipe_up_to_next_live(),它会执行 room_pos += 1
@@ -3806,28 +4079,73 @@ class fudai_analyse:
except Exception:
pass
delay_s = float(getattr(self, "reservation_back_swipe_delay", 0.6) or 0.6)
# 回退时设置标志,跳过记录标题(因为之前已经记录过了)
try:
self._skip_record_title_during_seek = True
except Exception:
pass
for _ in range(forward_times):
self.swipe_up_to_next_live()
try:
self.operation.delay(delay_s)
except Exception:
time.sleep(delay_s)
# 清除标志
try:
self._skip_record_title_during_seek = False
except Exception:
pass
# 回退完成后记录日志
try:
current_room_pos_after = int(getattr(self, "room_pos", cur_pos) or cur_pos)
self._log_kv(
"预约",
"[预约] _seek_reservation_room 回退完成",
target_room_title=target_room_title,
target_room_title_raw=target_room_title_raw,
target_pos=target_pos,
current_room_pos=int(getattr(self, "room_pos", cur_pos) or cur_pos),
current_room_pos=current_room_pos_after,
)
except Exception:
pass
# 回退过程中只执行回退操作,不进行校验或读取预约数据
# 回退完成后直接返回成功
# 回退完成后,从映射表中读取目标位置的标题进行验证
# 不需要再次记录标题,因为:
# 1. 在寻找福袋的过程中已经记录过直播间标题了
# 2. 回退时只需要滑动到目标位置,不需要再次记录
# 3. 直接使用映射表中已有的数据验证即可
try:
room_pos_map = getattr(self, "_room_pos_to_title_map", {})
if target_pos in room_pos_map:
recorded_title, recorded_title_raw = room_pos_map[target_pos]
try:
self._log_kv(
"预约",
"[预约] _seek_reservation_room 回退完成,从映射表验证标题",
target_pos=target_pos,
target_room_title=target_room_title[:50] if target_room_title else "",
recorded_room_title=recorded_title[:50] if recorded_title else "",
title_match=(target_room_title in recorded_title) or (recorded_title in target_room_title) if (target_room_title and recorded_title) else False,
)
except Exception:
pass
else:
try:
self._log_kv(
"预约",
"[预约] _seek_reservation_room 回退完成,但映射表中未找到目标位置",
target_pos=target_pos,
map_size=len(room_pos_map),
available_positions=list(room_pos_map.keys())[:10] if room_pos_map else [],
)
except Exception:
pass
except Exception:
pass
# 回退过程中只执行回退操作,不进行校验
# 校验将在 process_reservation_attend_window 中统一进行,使用映射表中的数据
return True
# ========== 福袋相关 ==========
@@ -3902,7 +4220,6 @@ class fudai_analyse:
self._current_fudai_future_ts = future_ts
# 直接调用参与决策,跳过详情识别
import douyin_fudai_core
join_result = douyin_fudai_core.basic_join_decision(self, detail)
# 如果参与成功,设置开奖等待状态并从预约队列中移除
@@ -4068,14 +4385,14 @@ class fudai_analyse:
# 注意:点击参与抽奖后会自动关闭详情页,下次循环会跳过阶段检测直接查找福袋
# 检查是否是第二次打开福袋详情(已经读取过详情)
# 如果是第二次打开,只需要验证参与按钮,不需要重新识别内容、倒计时、价值
# 如果是第二次打开,直接点击参与,不需要验证,使用第一次的倒计时
is_second_open = getattr(self, "_fudai_detail_first_read", False)
if is_second_open:
# 第二次打开:只检测参与按钮,使用第一次读取的详情数据
# 第二次打开:直接点击参与,不进行验证,使用第一次的倒计时
try:
self._log_kv(
"流程",
"_handle_in_fudai_detail:第二次打开,只验证参与按钮,跳过内容识别",
"_handle_in_fudai_detail:第二次打开,直接点击参与,跳过验证和内容识别",
)
except Exception:
pass
@@ -4098,120 +4415,66 @@ class fudai_analyse:
close_detail_callback=douyin_fudai_detail.close_fudai_detail,
ensure_open_callback=douyin_fudai_detail.ensure_fudai_detail_open,
)
# 重新读取后,更新保存的详情数据
if detail and isinstance(detail, tuple) and len(detail) >= 6:
self._last_fudai_detail_tuple = detail
else:
# 只检测参与按钮,不重新识别内容
# 使用第一次保存的详情数据,设置当前福袋的倒计时信息
try:
self.operation.get_screenshot(self.device_id)
self.cut_pic(306, 2030, 780, 2110, "", "参与按钮")
# OCR识别参与按钮
attend_button_text = str(
self.operation.analyse_pic_word("参与按钮", 0) or ""
)
if not attend_button_text or not any(
k in attend_button_text
for k in (
"参与成功",
"还需看播",
"评论",
"参与抽奖",
"开始观看",
"参与",
)
):
attend_button_text = str(
self.operation.analyse_pic_word("参与按钮", 1) or ""
)
self._log_kv(
"参与", "第二次打开:只验证参与按钮", text=attend_button_text
)
# 如果已参与,设置等待开奖标志并返回,不需要继续处理
if (
"参与成功" in attend_button_text
or "还需看播" in attend_button_text
or "等待开奖" in attend_button_text
):
self._log_kv(
"参与", "第二次打开:已参与,无需再次点击", result="已参与"
)
# 从第一次保存的详情数据中获取倒计时信息,设置等待开奖标志
try:
detail = getattr(self, "_last_fudai_detail_tuple", None)
if (
detail
and isinstance(detail, tuple)
and len(detail) >= 6
):
countdown_tuple = detail[5] # type: ignore[index]
if (
isinstance(countdown_tuple, (tuple, list))
and len(countdown_tuple) >= 2
):
future_ts = float(countdown_tuple[1] or 0.0)
if future_ts > 0:
current_time = time.time()
remain_seconds = int(future_ts - current_time)
if remain_seconds > 0:
# 设置等待开奖标志和预期开奖时间
# 提前13秒,修正倒计时误差
self._waiting_for_lottery_result = True
self._lottery_result_expected_ts = (
future_ts - 13.0
)
self._log_kv(
"参与",
"第二次打开:已参与,设置等待开奖标志",
remain_seconds=remain_seconds,
future_ts=int(future_ts),
)
else:
self._log_kv(
"参与",
"第二次打开:已参与,但倒计时已过期,不设置等待标志",
)
else:
self._log_kv(
"参与",
"第二次打开:已参与,但无法获取倒计时信息",
)
else:
self._log_kv(
"参与",
"第二次打开:已参与,但详情数据中无倒计时信息",
)
else:
if isinstance(detail, tuple) and len(detail) >= 6:
countdown_tuple = detail[5] # type: ignore[index]
if isinstance(countdown_tuple, (tuple, list)) and len(countdown_tuple) >= 2:
future_ts = float(countdown_tuple[1] or 0.0)
if future_ts > 0:
# 设置当前福袋的 future_ts,供 attend_choujiang 使用
self._current_fudai_future_ts = future_ts
self._log_kv(
"参与", "第二次打开:已参与,但未找到保存的详情数据"
"参与",
"第二次打开:使用第一次的倒计时信息",
future_ts=int(future_ts),
remain_seconds=int(future_ts - time.time()),
)
except Exception as e:
self._log_kv(
"参与",
"第二次打开:设置等待开奖标志时出错",
error=str(e),
)
# 关闭详情页
self.click(500, 470)
# 清除第一次读取标志,下次打开新福袋时重新识别
try:
self._fudai_detail_first_read = False
self._last_fudai_detail_tuple = None
except Exception:
pass
elapsed = time.time() - start_time
self._log_kv(
"流程",
"_handle_in_fudai_detail完成(第二次打开已参与)",
elapsed_seconds=round(elapsed, 2),
)
return
# 如果还需要参与,继续后续的参与决策流程
except Exception as e:
self._log_kv("参与", "第二次打开:验证参与按钮异常", error=str(e))
self._log_kv(
"参与",
"第二次打开:设置倒计时信息时出错",
error=str(e),
)
# 直接调用参与函数,不进行验证
try:
attend_result = douyin_fudai_core.attend_choujiang(self)
if attend_result:
self._log_kv(
"参与",
"第二次打开:直接点击参与成功",
result="参与成功",
)
else:
self._log_kv(
"参与",
"第二次打开:直接点击参与失败",
result="参与失败",
)
# 清除第一次读取标志,下次打开新福袋时重新识别
try:
self._fudai_detail_first_read = False
self._last_fudai_detail_tuple = None
except Exception:
pass
elapsed = time.time() - start_time
self._log_kv(
"流程",
"_handle_in_fudai_detail完成(第二次打开直接参与)",
elapsed_seconds=round(elapsed, 2),
attend_result=attend_result,
)
return
except Exception as e:
self._log_kv("参与", "第二次打开:直接点击参与异常", error=str(e))
# 异常时继续正常流程
else:
# 第一次打开:完整读取详情(包括内容、倒计时、价值)
@@ -4443,14 +4706,28 @@ class fudai_analyse:
start_y = 1700 * ry // 2400
end_x = 540 * rx // 1080
end_y = 700 * ry // 2400
self.operation.swipe(
self.device_id,
start_x,
start_y,
end_x,
end_y,
300,
)
# 直接使用 ADB 内部滑动命令
try:
import subprocess
if hasattr(self.operation, '_adb'):
adb_cmd = self.operation._adb()
else:
import os
adb_cmd = os.environ.get("ADB_EXECUTABLE", "adb") or "adb"
if not adb_cmd.startswith('"') and not adb_cmd.endswith('"'):
adb_cmd = f'"{adb_cmd}"'
cmd = f"{adb_cmd} -s {self.device_id} shell input swipe {start_x} {start_y} {end_x} {end_y} 300"
subprocess.run(cmd, shell=True, timeout=5.0, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except Exception:
# 回退到 operation.swipe
self.operation.swipe(
self.device_id,
start_x,
start_y,
end_x,
end_y,
300,
)
except Exception:
pass
@@ -4595,14 +4872,28 @@ class fudai_analyse:
start_y = 1700 * ry // 2400
end_x = 540 * rx // 1080
end_y = 700 * ry // 2400
self.operation.swipe(
self.device_id,
start_x,
start_y,
end_x,
end_y,
300,
)
# 直接使用 ADB 内部滑动命令
try:
import subprocess
if hasattr(self.operation, '_adb'):
adb_cmd = self.operation._adb()
else:
import os
adb_cmd = os.environ.get("ADB_EXECUTABLE", "adb") or "adb"
if not adb_cmd.startswith('"') and not adb_cmd.endswith('"'):
adb_cmd = f'"{adb_cmd}"'
cmd = f"{adb_cmd} -s {self.device_id} shell input swipe {start_x} {start_y} {end_x} {end_y} 300"
subprocess.run(cmd, shell=True, timeout=5.0, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except Exception:
# 回退到 operation.swipe
self.operation.swipe(
self.device_id,
start_x,
start_y,
end_x,
end_y,
300,
)
self.operation.delay(0.5)
except Exception:
pass
+1023 -96
View File
File diff suppressed because it is too large. Load diff
+279 -35
View File
@@ -17,6 +17,7 @@ from typing import Any, Dict, Tuple, List, Optional
import os
import time
import re
import sys
from PIL import Image
@@ -41,7 +42,8 @@ def _strip_room_noise_text(s: str) -> str:
"""移除直播间名 OCR 常见噪音(点赞/关注/粉丝等)。"""
try:
t = str(s or "")
except Exception:
except Exception as e:
# 字符串转换失败,返回空字符串
return ""
t = t.replace("\r", "\n").replace("\t", " ")
t = re.sub(r"[\s\u3000]+", " ", t).strip()
@@ -116,7 +118,18 @@ def _ocr_try_room_title(analyser: Any, cut_name: str, change_color: int) -> Tupl
"""尝试 OCR 识别直播间标题。"""
try:
raw0 = analyser.operation.analyse_pic_word(cut_name, change_color)
except Exception:
except Exception as e:
try:
analyser._log_kv(
"错误",
"OCR识别直播间标题失败",
error=str(e),
error_type=type(e).__name__,
cut_name=cut_name,
level="WARNING",
)
except Exception:
pass
raw0 = ""
raw_text0 = str(raw0 or "").replace("\r", "\n").strip()
cand_raw0 = _extract_room_title_candidate(raw_text0)
@@ -154,18 +167,130 @@ def _pick_best_room_title(cands: List[Tuple[str, str, str]], min_len: int = 3) -
def close_fudai_detail(analyser: Any) -> None:
"""关闭福袋详情:当前实现直接按一次返回键。"""
"""关闭福袋详情:使用点击关闭详情页的坐标,而不是返回键。"""
try:
analyser._log_kv("详情", "close_fudai_detail:按返回键一次")
except Exception:
pass
# 获取分辨率比例(基准分辨率 1080x2400)
rx = int(getattr(analyser, "resolution_ratio_x", 1080) or 1080)
ry = int(getattr(analyser, "resolution_ratio_y", 2400) or 2400)
# 计算关闭详情页的坐标(基准坐标 500, 470)
close_x = int(500 * rx // 1080)
close_y = int(470 * ry // 2400)
# 坐标验证:检查坐标是否在合理范围内
# 获取屏幕尺寸(如果可用)
screen_width = rx
screen_height = ry
try:
if hasattr(analyser, 'operation') and hasattr(analyser.operation, 'get_screen_size'):
try:
screen_size = analyser.operation.get_screen_size(analyser.device_id)
if screen_size:
screen_width, screen_height = screen_size
except Exception:
pass
except Exception:
pass
# 验证坐标边界
if close_x < 0 or close_x >= screen_width or close_y < 0 or close_y >= screen_height:
try:
analyser._log_kv(
"验证",
"关闭详情页坐标超出屏幕范围",
x=close_x,
y=close_y,
screen_width=screen_width,
screen_height=screen_height,
base_x=500,
base_y=470,
level="WARNING",
)
except Exception:
pass
# 修正坐标到屏幕范围内
close_x = max(0, min(close_x, screen_width - 1))
close_y = max(0, min(close_y, screen_height - 1))
analyser._log_kv(
"详情",
"close_fudai_detail:点击关闭详情页坐标",
x=close_x,
y=close_y,
base_x=500,
base_y=470,
)
except Exception as e:
# 如果获取分辨率失败,使用默认坐标
try:
analyser._log_kv(
"错误",
"获取分辨率失败,使用默认坐标",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
close_x, close_y = 500, 470
try:
analyser._log_kv("详情", "close_fudai_detail:使用默认坐标关闭详情页")
except Exception:
pass
try:
analyser.operation.click_back(analyser.device_id)
except Exception:
pass
analyser.operation.click(analyser.device_id, close_x, close_y)
except Exception as e1:
# 兜底:尝试使用 analyser.click
try:
analyser._log_kv(
"错误",
"使用operation.click关闭详情页失败,尝试备用方法",
error=str(e1),
error_type=type(e1).__name__,
level="WARNING",
)
except Exception:
pass
try:
analyser.click(close_x, close_y)
except Exception as e2:
# 最后兜底:使用返回键
try:
analyser._log_kv(
"错误",
"使用analyser.click关闭详情页失败,使用返回键",
error=str(e2),
error_type=type(e2).__name__,
level="WARNING",
)
except Exception:
pass
try:
analyser.operation.click_back(analyser.device_id)
except Exception as e3:
try:
analyser._log_kv(
"错误",
"所有关闭详情页方法都失败",
error=str(e3),
error_type=type(e3).__name__,
level="ERROR",
)
except Exception:
pass
try:
analyser.operation.delay(0.5)
except Exception:
except Exception as e:
try:
analyser._log_kv(
"错误",
"operation.delay失败,使用time.sleep",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
time.sleep(0.5)
@@ -178,8 +303,17 @@ def ensure_fudai_detail_open(analyser: Any, fudai_x: int = 0) -> bool:
"""
try:
analyser._log_kv("详情", "ensure_fudai_detail_open:假定已打开", fudai_x=fudai_x)
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"错误",
"记录ensure_fudai_detail_open日志失败",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
return True
@@ -194,7 +328,17 @@ def _is_wrong_coupon_popup(analyser: Any) -> bool:
"""
try:
analyser.operation.get_screenshot(analyser.device_id)
except Exception:
except Exception as e:
try:
analyser._log_kv(
"错误",
"获取截图失败(判断优惠券弹窗)",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
return False
path = os.path.join(os.path.dirname(__file__), "pic", "screenshot.png")
@@ -238,7 +382,8 @@ def _is_wrong_coupon_popup(analyser: Any) -> bool:
for xx in range(x1, x2, step_x):
try:
p = pix[xx, yy]
except Exception:
except Exception as e:
# 像素访问失败,跳过该像素(可能是坐标越界)
continue
if not (isinstance(p, tuple) and len(p) >= 3):
continue
@@ -257,8 +402,17 @@ def _is_wrong_coupon_popup(analyser: Any) -> bool:
fudai_like=fudai_like,
coupon_like=coupon_like,
)
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"错误",
"记录弹窗颜色统计日志失败",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
# 如果券像素明显多于粉袋像素,可能需要OCR确认
is_coupon_like_by_color = coupon_like > fudai_like * 1.2
@@ -293,12 +447,30 @@ def _is_wrong_coupon_popup(analyser: Any) -> bool:
task_count=task_count,
method=detection_method,
)
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"错误",
"记录福袋详情检测日志失败",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
else:
has_fudai_detail = result
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"错误",
"检测福袋详情页失败",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
# 如果颜色统计显示可能是优惠券,需要严格确认:
# 1. 先进行模板匹配确认(使用 detect_coupon_popup_background)
@@ -315,7 +487,13 @@ def _is_wrong_coupon_popup(analyser: Any) -> bool:
template_matched = douyin_pixel.detect_coupon_popup_background(pic_rgb)
except Exception as e:
try:
analyser._log_kv("弹窗", "模板匹配确认异常", error=str(e))
analyser._log_kv(
"错误",
"模板匹配确认异常",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
@@ -328,8 +506,17 @@ def _is_wrong_coupon_popup(analyser: Any) -> bool:
"颜色统计偏向优惠券,但模板匹配未命中,不判定为优惠券弹窗",
说明="可能是识别福袋位置失败,点击了错误位置",
)
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"错误",
"记录模板匹配失败日志失败",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
return False
# 步骤2:OCR确认"开心收下"按钮(模板匹配成功后)
@@ -383,10 +570,28 @@ def _is_wrong_coupon_popup(analyser: Any) -> bool:
"OCR识别前保存完整截图(参与按钮-检测开心收下)",
path=debug_path,
)
except Exception:
pass
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"错误",
"记录调试图像日志失败",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"错误",
"保存参与按钮调试截图失败",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
analyser.cut_pic(200, 1940, 880, 2140, "", "参与按钮")
@@ -437,7 +642,13 @@ def _is_wrong_coupon_popup(analyser: Any) -> bool:
except Exception as e:
# 确认过程异常,不判定为优惠券弹窗,避免误判
try:
analyser._log_kv("弹窗", "优惠券确认过程异常,不判定为优惠券弹窗", error=str(e))
analyser._log_kv(
"错误",
"优惠券确认过程异常,不判定为优惠券弹窗",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
return False
@@ -457,8 +668,17 @@ def read_live_room_title_core(
"""
try:
analyser.operation.get_screenshot(analyser.device_id)
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"错误",
"获取截图失败(读取直播间标题)",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
cands: List[Tuple[str, str, str]] = []
@@ -470,8 +690,17 @@ def read_live_room_title_core(
if len(t or "") < min_len:
t1, r1 = _ocr_try_room_title(analyser, 'live_room_title_mid', 1)
cands.append((t1, r1, 'mid_cc1'))
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"错误",
"OCR识别直播间标题(mid区域)失败",
error=str(e),
error_type=type(e).__name__,
level="WARNING",
)
except Exception:
pass
# large ROI:进一步扩大,兼容机型/系统字体/刘海偏移
if not cands or max(len(x[0] or "") for x in cands) < min_len:
@@ -725,6 +954,13 @@ def read_fudai_detail_once(analyser: Any) -> Tuple[str, Tuple, dict]:
# 输出完整的识别结果到运行日志
content_preview = (content or "")[:60] if content else "未识别到"
content_full = content or ""
# 添加明确的"福袋内容:"格式输出,确保GUI能正确解析(即使内容为空也输出)
analyser._log_kv(
"福袋",
f"福袋内容:{content_full[:200] if content_full else '未识别到'}", # 使用明确的"福袋内容:"格式,确保GUI能解析
level="INFO",
)
analyser._log_kv(
"福袋详情",
f"read_fudai_detail_once 完整识别结果:内容={content_preview},价值={float(prize_value_yuan or 0.0)}元,倒计时={time_text or '未识别'},剩余{remain_seconds}秒",
@@ -732,8 +968,8 @@ def read_fudai_detail_once(analyser: Any) -> Tuple[str, Tuple, dict]:
room_title=room_title,
room_title_raw=room_title_raw,
task_count=task_count,
content=content or "",
content_length=len(content or ""),
content=content_full,
content_length=len(content_full),
time_text=time_text or "",
participants=int(participants or 0),
copies=int(copies or 0),
@@ -1128,13 +1364,21 @@ def read_fudai_detail_with_retries(
try:
# 运行日志:完整的福袋详情
content_preview = (content or "")[:60] if content else "未识别到"
content_full = content or ""
# 添加明确的"福袋内容:"格式输出,确保GUI能正确解析(即使内容为空也输出)
if last_status == "ok":
analyser._log_kv(
"福袋",
f"福袋内容:{content_full[:200] if content_full else '未识别到'}", # 使用明确的"福袋内容:"格式,确保GUI能解析
level="INFO",
)
analyser._log_kv(
"福袋详情",
f"read_fudai_detail_with_retries 最终结果:内容={content_preview},价值={float(prize_value_yuan or 0.0)}元,倒计时={time_text or '未识别'},剩余{remain_seconds}秒",
status=last_status,
room_title=room_title,
room_title_raw=room_title_raw,
content=content,
content=content_full,
time_text=time_text,
participants=participants,
copies=copies,
+412 -50
View File
@@ -652,15 +652,12 @@ def handle_queue_full_wait_at_earliest(
target_pos = 0
pos_diff = current_room_pos - target_pos
# 如果已经在目标位置(pos_diff == 0),不需要先回退,直接调用回调
# 如果不在目标位置,先轻微下滑一次,确保在直播列表中
if pos_diff != 0:
try:
swipe_down_back_callback()
time.sleep(max(0.1, float(reservation_back_swipe_delay_s or 0.0)))
except Exception:
pass
# 直接调用回退回调,不需要预先下滑
# 原因:
# 1. 回退前已经进行了阶段诊断,处理了弹窗和福袋详情页等异常状态
# 2. 如果已经在直播间,不需要下滑
# 3. 预先下滑会导致 room_pos 减1,影响后续的回退计算,导致少回退一个直播间
# 回退到最早开奖的预约直播间
ok = False
try:
@@ -1165,15 +1162,11 @@ def process_reservation_attend_window(
except Exception:
pass
# 如果已经在目标位置(pos_diff == 0),不需要先回退,直接调用回调
# 如果不在目标位置,先轻微下滑一次,确保在直播列表中 / 或触发系统返回
if pos_diff != 0:
try:
swipe_down_back_callback()
time.sleep(max(0.1, float(reservation_back_swipe_delay_s or 0.0)))
except Exception:
pass
# 直接调用回退回调,不需要预先下滑
# 原因:
# 1. 回退前已经进行了阶段诊断,处理了弹窗和福袋详情页等异常状态
# 2. 如果已经在直播间,不需要下滑
# 3. 预先下滑会导致 room_pos 减1,影响后续的回退计算,导致少回退一个直播间
ok = False
try:
ok = bool(seek_reservation_room_callback(target))
@@ -1190,6 +1183,265 @@ def process_reservation_attend_window(
ok = False
if ok:
# 获取目标直播间名字和福袋详情(用于日志和校验)
target_room_title = str(target.get("room_title") or "").strip()
target_room_title_raw = str(target.get("room_title_raw") or "").strip()
target_content = str(target.get("content") or "").strip()
target_value = float(target.get("prize_value_yuan") or 0.0)
try:
analyser._log_kv(
"预约",
"[预约] process_reservation_attend_window:回退操作成功,准备进行回退校验",
target_pos=int(target.get("pos_seen", 0)),
target_room_title=target_room_title[:50] if target_room_title else "",
target_room_title_raw=target_room_title_raw[:50] if target_room_title_raw else "",
target_content=target_content[:50] if target_content else "",
target_value_yuan=target_value,
current_room_pos=int(room_pos),
reservation_back_verify_enabled=bool(getattr(analyser, "reservation_back_verify_enabled", True)),
level="DEBUG",
)
except Exception:
pass
# 回退成功后,进行回退校验(如果启用了回退校验)
verify_ok = True
verify_detail = None
try:
verify_enabled = bool(getattr(analyser, "reservation_back_verify_enabled", True))
try:
analyser._log_kv(
"预约",
"[预约] process_reservation_attend_window:检查回退校验开关",
reservation_back_verify_enabled=verify_enabled,
level="DEBUG",
)
except Exception:
pass
if verify_enabled:
try:
try:
analyser._log_kv(
"预约",
"[预约] process_reservation_attend_window:开始调用回退校验函数",
target_pos=int(target.get("pos_seen", 0)),
target_room_title=target_room_title[:50] if target_room_title else "",
level="DEBUG",
)
except Exception:
pass
import douyin_reservation_verify
verify_ok, verify_detail = douyin_reservation_verify.validate_back_to_reservation(
analyser=analyser,
item=target,
quick=False,
max_checks=3,
)
try:
analyser._log_kv(
"预约",
"[预约] process_reservation_attend_window:回退校验函数返回",
verify_ok=verify_ok,
verify_detail_exists=verify_detail is not None,
level="DEBUG",
)
except Exception:
pass
if not verify_ok:
try:
analyser._log_kv(
"预约",
"[预约] 回退校验失败:回退操作成功但校验未通过,尝试根据映射表自动回退到正确位置",
target_pos=int(target.get("pos_seen", 0)),
target_room_title=target_room_title[:50] if target_room_title else "",
)
except Exception:
pass
# 校验失败,尝试根据映射表查找正确位置并自动回退
try:
if hasattr(analyser, "_find_room_pos_by_title"):
correct_pos = analyser._find_room_pos_by_title(
target_room_title, target_room_title_raw
)
if correct_pos is not None and correct_pos != int(target.get("pos_seen", 0)):
try:
analyser._log_kv(
"预约",
"[预约] 根据映射表找到正确位置,自动回退",
original_target_pos=int(target.get("pos_seen", 0)),
correct_pos=correct_pos,
target_room_title=target_room_title[:50] if target_room_title else "",
)
except Exception:
pass
# 更新目标位置并重新回退
target["pos_seen"] = correct_pos
try:
retry_ok = bool(seek_reservation_room_callback(target))
if retry_ok:
# 重新进行校验
try:
verify_ok_retry, verify_detail_retry = douyin_reservation_verify.validate_back_to_reservation(
analyser=analyser,
item=target,
quick=False,
max_checks=3,
)
if verify_ok_retry:
try:
analyser._log_kv(
"预约",
"[预约] 根据映射表自动回退后校验通过",
correct_pos=correct_pos,
target_room_title=target_room_title[:50] if target_room_title else "",
)
except Exception:
pass
verify_ok = True
verify_detail = verify_detail_retry
ok = True
else:
try:
analyser._log_kv(
"预约",
"[预约] 根据映射表自动回退后校验仍失败",
correct_pos=correct_pos,
target_room_title=target_room_title[:50] if target_room_title else "",
)
except Exception:
pass
ok = False
except Exception as e:
try:
analyser._log_kv(
"预约",
"[预约] 根据映射表自动回退后重新校验时出错",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
ok = False
else:
try:
analyser._log_kv(
"预约",
"[预约] 根据映射表自动回退操作失败",
correct_pos=correct_pos,
)
except Exception:
pass
ok = False
except Exception as e:
try:
analyser._log_kv(
"预约",
"[预约] 根据映射表自动回退时出错",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
ok = False
elif correct_pos is None:
try:
analyser._log_kv(
"预约",
"[预约] 映射表中未找到目标直播间,无法自动回退",
target_room_title=target_room_title[:50] if target_room_title else "",
)
except Exception:
pass
ok = False
else:
try:
analyser._log_kv(
"预约",
"[预约] 映射表中的位置与目标位置相同,但校验仍失败",
target_pos=int(target.get("pos_seen", 0)),
)
except Exception:
pass
ok = False
else:
ok = False
except Exception as e:
try:
analyser._log_kv(
"预约",
"[预约] 根据映射表自动回退时发生异常",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
ok = False
else:
try:
analyser._log_kv(
"预约",
"[预约] 回退校验通过:已成功回退到目标直播间并验证福袋详情",
target_pos=int(target.get("pos_seen", 0)),
target_room_title=target_room_title[:50] if target_room_title else "",
)
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"预约",
"[预约] 回退校验执行时发生异常,继续执行",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
# 校验异常不影响主流程,继续执行
else:
try:
analyser._log_kv(
"预约",
"[预约] 回退校验已禁用,跳过校验",
)
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"预约",
"[预约] 检查回退校验开关时发生异常,继续执行",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
# 如果回退或校验失败,直接返回 False
if not ok:
try:
analyser._log_kv(
"预约",
"[预约] 回退或校验失败,保留队列以便后续重试或清理",
future_ts=int(ft),
now_ts=int(now_ts),
remain_seconds_to_open=int(ft - now_ts),
target_pos=int(target.get("pos_seen", 0)),
current_room_pos=int(room_pos),
)
except Exception:
pass
try:
write_state_callback()
except Exception:
pass
return False
# 进入锁定期:在开奖附近一段时间内不再切换直播间
focus_until_new = ft + max(0.0, poll_before)
if reservation_focus_until_ts_ref:
@@ -1201,14 +1453,6 @@ def process_reservation_attend_window(
reservation_after_action_pending_ref[0] = True
else:
reservation_after_action_pending_ref.append(True)
# 回退过程中只执行回退操作,不进行校验或读取预约数据
# 获取目标直播间名字和福袋详情
target_room_title = str(target.get("room_title") or "").strip()
target_room_title_raw = str(target.get("room_title_raw") or "").strip()
target_content = str(target.get("content") or "").strip()
target_value = float(target.get("prize_value_yuan") or 0.0)
try:
from datetime import datetime
@@ -1344,6 +1588,37 @@ def record_high_value_reservation(
- 返回 False,表示当前轮不需要立即抢占主流程。
"""
try:
# 验证输入参数
try:
if not isinstance(fudai_content_text, str):
fudai_content_text = str(fudai_content_text or "")
if not isinstance(prize_value_yuan, (int, float)):
prize_value_yuan = float(prize_value_yuan or 0.0)
if not isinstance(future_timestamp, (int, float)) or future_timestamp <= 0:
try:
analyser._log_kv(
"预约",
"[预约] record_high_value_reservation:future_timestamp 无效",
future_timestamp=future_timestamp,
error_type="InvalidParameter",
)
except Exception:
pass
return False
if not isinstance(room_pos, int):
room_pos = int(room_pos or 0)
except Exception as e:
try:
analyser._log_kv(
"预约",
"[预约] record_high_value_reservation:参数验证失败",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
return False
# 计算 future_str(预计开奖时间的字符串格式)
future_str = ""
try:
@@ -1353,32 +1628,106 @@ def record_high_value_reservation(
future_str = datetime.fromtimestamp(float(future_timestamp)).strftime(
"%Y-%m-%d %H:%M:%S"
)
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"预约",
"[预约] record_high_value_reservation:计算 future_str 失败",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
item: ReservationItem = {
"future_ts": float(future_timestamp or 0.0),
"future_str": future_str,
"prize_value_yuan": float(prize_value_yuan or 0.0),
"content": str(fudai_content_text or ""),
"pos_seen": int(room_pos),
"created_ts": _now_ts(),
"room_title": str(room_title or ""),
"room_title_raw": str(room_title_raw or ""),
"task_count": int(task_count or 2),
"time_text": str(time_text or ""),
"participants": int(participants or 0),
"copies": int(copies or 0),
}
# 验证 reservations 列表
if not isinstance(reservations, list):
try:
analyser._log_kv(
"预约",
"[预约] record_high_value_reservation:reservations 不是列表",
reservations_type=type(reservations).__name__,
error_type="InvalidParameter",
)
except Exception:
pass
return False
add_reservation_callback(reservations, item)
sort_reservations_callback()
# 构造预约项
try:
item: ReservationItem = {
"future_ts": float(future_timestamp or 0.0),
"future_str": future_str,
"prize_value_yuan": float(prize_value_yuan or 0.0),
"content": str(fudai_content_text or ""),
"pos_seen": int(room_pos),
"created_ts": _now_ts(),
"room_title": str(room_title or ""),
"room_title_raw": str(room_title_raw or ""),
"task_count": int(task_count or 2),
"time_text": str(time_text or ""),
"participants": int(participants or 0),
"copies": int(copies or 0),
}
except Exception as e:
try:
analyser._log_kv(
"预约",
"[预约] record_high_value_reservation:构造预约项失败",
error=str(e),
error_type=type(e).__name__,
prize_value_yuan=prize_value_yuan,
future_timestamp=future_timestamp,
room_pos=room_pos,
)
except Exception:
pass
return False
# 调用回调函数添加预约
try:
add_reservation_callback(reservations, item)
except Exception as e:
try:
analyser._log_kv(
"预约",
"[预约] record_high_value_reservation:add_reservation_callback 失败",
error=str(e),
error_type=type(e).__name__,
queue_len_before=len(reservations),
)
except Exception:
pass
return False
# 排序预约队列
try:
sort_reservations_callback()
except Exception as e:
try:
analyser._log_kv(
"预约",
"[预约] record_high_value_reservation:sort_reservations_callback 失败",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
# 写入状态文件
try:
write_state_callback()
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"预约",
"[预约] record_high_value_reservation:write_state_callback 失败",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
# 记录成功日志
try:
from datetime import datetime
created_str = datetime.fromtimestamp(item["created_ts"]).strftime("%Y-%m-%d %H:%M:%S")
@@ -1399,17 +1748,30 @@ def record_high_value_reservation(
copies=copies,
queue_len=len(reservations),
)
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"预约",
"[预约] record_high_value_reservation:记录成功日志失败",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
return False
except Exception:
except Exception as e:
# 任何异常都不影响主流程,只记录日志
try:
analyser._log_kv(
"预约",
"[预约] record_high_value_reservation 异常,忽略本次预约",
error_type="Exception",
error=str(e),
error_type=type(e).__name__,
prize_value_yuan=prize_value_yuan,
future_timestamp=future_timestamp,
room_pos=room_pos,
room_title=room_title[:50] if room_title else "",
)
except Exception:
pass
+222 -167
View File
@@ -155,21 +155,40 @@ def validate_back_to_reservation(
quick: bool = False,
max_checks: int = 3,
) -> Tuple[bool, Optional[Tuple]]:
"""回退后校验:必须看到福袋并且详情匹配预约。
"""回退后校验:只校验直播间标题,不校验福袋。
如果直播间标题不符合,则根据映射表找到正确位置并回退。
参数:
analyser: 分析器对象
item: 预约项字典
quick: 是否快速模式(减少检查次数)
max_checks: 最大检查次数
max_checks: 最大检查次数(未使用,保留兼容性)
返回:
(is_valid, detail_tuple) - 如果校验通过,返回详情 tuple,否则返回 None
(is_valid, None) - 如果校验通过返回 True,否则返回 False
"""
try:
analyser._log_kv(
"预约",
"[预约] validate_back_to_reservation:函数入口",
target_pos=int(item.get("pos_seen", 0)),
target_room_title=str(item.get("room_title", ""))[:50],
quick=quick,
max_checks=max_checks,
level="DEBUG",
)
except Exception:
pass
# 若开关关闭,则跳过复杂校验,直接认为回退成功以加速流程
try:
if not bool(getattr(analyser, "reservation_back_verify_enabled", True)):
analyser._log_kv("预约", "回退校验已被禁用:跳过校验")
verify_enabled = bool(getattr(analyser, "reservation_back_verify_enabled", True))
if not verify_enabled:
try:
analyser._log_kv("预约", "回退校验已被禁用:跳过校验", level="DEBUG")
except Exception:
pass
return True, None
except Exception:
pass
@@ -195,6 +214,65 @@ def validate_back_to_reservation(
expected_title = str(item.get("room_title") or "").strip()
expected_title_raw = str(item.get("room_title_raw") or "").strip()
# 使用运行时映射表验证位置信息
target_pos_seen = int(item.get("pos_seen") or 0)
try:
room_pos_map = getattr(analyser, "_room_pos_to_title_map", {})
if target_pos_seen in room_pos_map:
recorded_title, recorded_title_raw = room_pos_map[target_pos_seen]
try:
analyser._log_kv(
"预约",
"回退校验:运行时映射表验证位置信息",
target_pos=target_pos_seen,
expected_room_title=expected_title[:50] if expected_title else "",
recorded_room_title=recorded_title[:50] if recorded_title else "",
expected_room_title_raw=expected_title_raw[:50] if expected_title_raw else "",
recorded_room_title_raw=recorded_title_raw[:50] if recorded_title_raw else "",
)
except Exception:
pass
# 如果映射表中的标题与预期标题匹配,增强验证信心
if expected_title and recorded_title:
try:
import douyin_high_value_room
if hasattr(douyin_high_value_room, '_normalize_room_title'):
expected_norm = douyin_high_value_room._normalize_room_title(expected_title) # type: ignore[attr-defined]
recorded_norm = douyin_high_value_room._normalize_room_title(recorded_title) # type: ignore[attr-defined]
if expected_norm == recorded_norm or expected_norm in recorded_norm or recorded_norm in expected_norm:
try:
analyser._log_kv(
"预约",
"回退校验:运行时映射表验证通过,位置和标题匹配",
target_pos=target_pos_seen,
)
except Exception:
pass
except Exception:
pass
else:
try:
analyser._log_kv(
"预约",
"回退校验:运行时映射表中未找到目标位置",
target_pos=target_pos_seen,
map_size=len(room_pos_map),
available_positions=list(room_pos_map.keys())[:10] if room_pos_map else [],
)
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"预约",
"回退校验:运行时映射表验证时出错",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
if expected_title:
try:
y_pianyi_val = int(getattr(analyser, "y_pianyi", 0) or 0)
@@ -228,178 +306,155 @@ def validate_back_to_reservation(
except Exception:
pass
# 强不匹配:直接失败(避免打开错误福袋详情浪费时间)
# 强不匹配:根据映射表找到正确位置并回退
if current_title and (expected_title not in current_title) and (current_title not in expected_title) and ratio < 0.45:
return False, None
try:
analyser._log_kv(
"预约",
"回退校验:直播间标题不匹配,尝试根据映射表找到正确位置",
expected_title=expected_title[:50] if expected_title else "",
current_title=current_title[:50] if current_title else "",
ratio=round(ratio, 3),
)
except Exception:
pass
# 根据映射表找到正确位置
try:
if hasattr(analyser, "_find_room_pos_by_title"):
correct_pos = analyser._find_room_pos_by_title(expected_title, expected_title_raw)
if correct_pos is not None:
try:
analyser._log_kv(
"预约",
"回退校验:在映射表中找到正确位置,准备回退",
correct_pos=correct_pos,
current_pos=int(getattr(analyser, "room_pos", 0) or 0),
expected_title=expected_title[:50] if expected_title else "",
)
except Exception:
pass
# 回退到正确位置
try:
# 更新 item 中的 pos_seen
item["pos_seen"] = correct_pos
# 调用回退函数
if hasattr(analyser, "_seek_reservation_room"):
seek_ok = analyser._seek_reservation_room(item)
if seek_ok:
# 重新读取标题验证
try:
y_pianyi_val = int(getattr(analyser, "y_pianyi", 0) or 0)
new_title, new_title_raw = douyin_fudai_detail.read_live_room_title_core(
analyser, y_pianyi_val
)
if new_title:
new_ratio = 0.0
try:
new_ratio = float(difflib.SequenceMatcher(None, expected_title, new_title).ratio())
except Exception:
pass
if (expected_title in new_title) or (new_title in expected_title) or new_ratio >= 0.45:
try:
analyser._log_kv(
"预约",
"回退校验:根据映射表回退后,标题匹配成功",
expected_title=expected_title[:50] if expected_title else "",
new_title=new_title[:50] if new_title else "",
new_ratio=round(new_ratio, 3),
)
except Exception:
pass
return True, None
else:
try:
analyser._log_kv(
"预约",
"回退校验:根据映射表回退后,标题仍不匹配",
expected_title=expected_title[:50] if expected_title else "",
new_title=new_title[:50] if new_title else "",
new_ratio=round(new_ratio, 3),
)
except Exception:
pass
return False, None
except Exception as e:
try:
analyser._log_kv(
"预约",
"回退校验:根据映射表回退后,重新读取标题失败",
error=str(e),
)
except Exception:
pass
return False, None
else:
try:
analyser._log_kv(
"预约",
"回退校验:根据映射表回退失败",
)
except Exception:
pass
return False, None
except Exception as e:
try:
analyser._log_kv(
"预约",
"回退校验:根据映射表回退时出错",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
return False, None
else:
try:
analyser._log_kv(
"预约",
"回退校验:映射表中未找到匹配的标题",
expected_title=expected_title[:50] if expected_title else "",
)
except Exception:
pass
return False, None
else:
try:
analyser._log_kv(
"预约",
"回退校验:analyser 没有 _find_room_pos_by_title 方法",
)
except Exception:
pass
return False, None
except Exception as e:
try:
analyser._log_kv(
"预约",
"回退校验:根据映射表查找位置时出错",
error=str(e),
error_type=type(e).__name__,
)
except Exception:
pass
return False, None
except Exception as e:
try:
analyser._log_kv("预约", "回退校验:读取直播间标题失败", error=str(e))
except Exception:
pass
# 检测福袋图标
x2 = 0
check_count = 1 if quick else max_checks
for i in range(check_count):
try:
import douyin_detection
analyser.operation.get_screenshot(analyser.device_id)
x2 = douyin_detection.check_have_fudai_with_ready_screenshot(analyser, screenshot_ready=True)
if x2 and x2 > 0:
break
except Exception:
x2 = 0
if i < check_count - 1:
try:
analyser._log_kv("预约", "回退校验:未发现福袋", attempt=i + 1)
except Exception:
pass
try:
analyser.operation.delay(0.5 if quick else 1.0)
except Exception:
time.sleep(0.5 if quick else 1.0)
if not x2 or x2 <= 0:
try:
analyser._log_kv("预约", "回退校验失败:未发现福袋", result="未发现福袋")
except Exception:
pass
return False, None
# 打开详情并确认进入详情页(避免点击后截图过早导致读错屏)
try:
analyser.click(x2, 400) # 点击福袋图标
analyser.operation.delay(0.8 if quick else 1.5)
except Exception:
try:
analyser.operation.click(analyser.device_id, x2, 400)
analyser.operation.delay(0.8 if quick else 1.5)
except Exception:
pass
# 确认是否在详情页
try:
import douyin_stage
analyser.operation.get_screenshot(analyser.device_id)
result = douyin_stage.diagnose_stage_from_current_screen(analyser)
if result is None:
stage = "IN_LIVE_ROOM"
else:
stage, _ = result
if stage != "FUDai_DETAIL":
try:
analyser._log_kv("预约", "回退校验失败:未能打开福袋详情", result="详情未打开", stage=stage)
except Exception:
pass
return False, None
except Exception:
pass
# 详情页刚出现时可能仍在动画/加载,稍等再识别更稳定
analyser.operation.delay(0.6 if quick else 1.1)
# 读取详情
# 如果标题匹配或没有标题,校验通过
try:
detail2 = douyin_fudai_detail.read_fudai_detail_with_retries(
analyser,
fudai_x=x2,
read_once_callback=douyin_fudai_detail.read_fudai_detail_once,
close_detail_callback=douyin_fudai_detail.close_fudai_detail,
ensure_open_callback=douyin_fudai_detail.ensure_fudai_detail_open,
)
if not detail2 or not isinstance(detail2, tuple) or len(detail2) < 6:
try:
analyser._log_kv("预约", "回退校验失败:详情读取异常", result="详情异常")
except Exception:
pass
# 确保关闭详情
try:
douyin_fudai_detail.close_fudai_detail(analyser)
except Exception:
pass
return False, None
except Exception as e:
try:
analyser._log_kv("预约", "回退校验失败:详情读取异常", error=str(e))
except Exception:
pass
try:
douyin_fudai_detail.close_fudai_detail(analyser)
except Exception:
pass
return False, None
# 匹配校验
ok, reason, dbg = match_reservation(item, detail2)
if not ok:
try:
analyser._log_kv("预约", "回退校验失败:福袋详情不匹配", result="不匹配", reason=reason, **dbg)
except Exception:
pass
try:
douyin_fudai_detail.close_fudai_detail(analyser)
except Exception:
pass
return False, None
# 校验通过,提取福袋详情
fc, tt, participants, copies, pv, cd = detail2[:6]
try:
remain_seconds = 0
if isinstance(cd, (tuple, list)) and len(cd) >= 2:
cd_end = float(cd[1] or 0.0)
remain_seconds = int(cd_end - time.time()) if cd_end > time.time() else 0
from datetime import datetime
cd_end_str = ""
if isinstance(cd, (tuple, list)) and len(cd) >= 2:
cd_end_val = float(cd[1] or 0.0)
if cd_end_val > 0:
cd_end_str = datetime.fromtimestamp(cd_end_val).strftime("%Y-%m-%d %H:%M:%S")
# 运行日志:添加福袋详情
analyser._log_kv(
"预约",
"回退校验通过:福袋详情匹配",
reason=reason,
target_room_title=str(item.get("room_title") or "").strip(),
target_room_title_raw=str(item.get("room_title_raw") or "").strip(),
fudai_content=str(fc or ""),
fudai_time_text=str(tt or ""),
fudai_participants=int(participants or 0),
fudai_copies=int(copies or 0),
fudai_value_yuan=float(pv or 0.0),
fudai_countdown_end=cd_end_str if cd_end_str else "",
fudai_remain_seconds=remain_seconds,
**dbg
"回退校验通过:直播间标题匹配",
target_room_title=str(item.get("room_title") or "").strip()[:50],
)
# 行为日志:添加福袋详情
analyser._log_kv(
"行为",
"回退校验通过:福袋详情匹配",
action="回退校验",
result="成功",
detail={
"目标直播间": str(item.get("room_title") or "").strip(),
"目标直播间原始": str(item.get("room_title_raw") or "").strip(),
"福袋内容": str(fc or ""),
"倒计时文本": str(tt or ""),
"参与人数": int(participants or 0),
"福袋份数": int(copies or 0),
"奖品价值": float(pv or 0.0),
"倒计时结束时间": cd_end_str if cd_end_str else "",
"剩余秒数": remain_seconds,
"校验原因": reason,
},
)
except Exception as e:
# 如果提取详情失败,至少记录基本信息
try:
analyser._log_kv("预约", "回退校验通过:福袋详情匹配", reason=reason, error=str(e), **dbg)
except Exception:
pass
except Exception:
pass
return True, detail2
return True, None
+84 -20
View File
@@ -1,11 +1,54 @@
from __future__ import annotations
from typing import Any
import subprocess
import os
def _adb_swipe_direct(device_id: str, start_x: int, start_y: int, end_x: int, end_y: int, duration_ms: int = 300, operation=None) -> bool:
"""直接使用 ADB 内部滑动命令执行滑动操作。
Args:
device_id: 设备 ID
start_x: 起始 X 坐标
start_y: 起始 Y 坐标
end_x: 结束 X 坐标
end_y: 结束 Y 坐标
duration_ms: 滑动持续时间(毫秒)
operation: operation 对象,用于获取 ADB 路径(可选)
Returns:
True 如果成功,False 如果失败
"""
try:
# 获取 ADB 命令路径
if operation and hasattr(operation, '_adb'):
adb_cmd = operation._adb()
else:
adb_cmd = os.environ.get("ADB_EXECUTABLE", "adb") or "adb"
if not adb_cmd.startswith('"') and not adb_cmd.endswith('"'):
adb_cmd = f'"{adb_cmd}"'
# 直接使用 ADB 命令执行滑动
cmd = f"{adb_cmd} -s {device_id} shell input swipe {start_x} {start_y} {end_x} {end_y} {duration_ms}"
result = subprocess.run(
cmd,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
timeout=5.0,
text=True,
)
return result.returncode == 0
except Exception:
return False
def swipe_up_switch_live(analyser: Any) -> None:
"""上滑切换到下一个直播间(基础版封装)。
直接使用 ADB 内部滑动命令,不通过坐标计算。
采用 1080x2400 基准坐标,在屏幕中下部向上滑一段距离。
"""
try:
@@ -20,10 +63,11 @@ def swipe_up_switch_live(analyser: Any) -> None:
device_id = getattr(analyser, "device_id", "")
# 基准坐标(1080x2400):从中下部往上滑
# 减少滑动距离:从 1700 到 1000,距离约 700 像素(原来约 1000 像素)
start_x_base = 540
start_y_base = 1700
end_x_base = 540
end_y_base = 700
end_y_base = 1000
start_x = start_x_base * rx // 1080
end_x = end_x_base * rx // 1080
@@ -33,7 +77,7 @@ def swipe_up_switch_live(analyser: Any) -> None:
try:
analyser._log_kv(
"滑动",
"swipe_up_switch_live:上滑切换直播间",
"swipe_up_switch_live:上滑切换直播间(使用 ADB 内部滑动)",
start_x=start_x_base,
start_y=start_y_base,
end_x=end_x_base,
@@ -49,21 +93,31 @@ def swipe_up_switch_live(analyser: Any) -> None:
except Exception:
pass
# 优先调用底层 swipe,失败则静默忽略(不影响主流程)
try:
# 执行滑动操作:从 (start_x, start_y) 滑到 (end_x, end_y)
analyser.operation.swipe(device_id, start_x, start_y, end_x, end_y, 300)
except Exception:
# 直接使用 ADB 内部滑动命令
# 增加滑动持续时间(从 300ms 增加到 600ms),确保滑动更稳定
# 滑动距离约 1000 像素,600ms 的速度更接近真实用户操作
swipe_duration_ms = 600
success = _adb_swipe_direct(device_id, start_x, start_y, end_x, end_y, swipe_duration_ms, analyser.operation)
if not success:
# 如果失败,尝试使用基准坐标(不缩放)
_adb_swipe_direct(device_id, start_x_base, start_y_base, end_x_base, end_y_base, swipe_duration_ms, analyser.operation)
# 如果还是失败,回退到 operation.swipe
try:
# 如果 analyser 自身提供 swipe 封装,则退回到该封装
analyser.swipe(start_x_base, start_y_base, end_x_base, end_y_base, 300)
analyser.operation.swipe(device_id, start_x, start_y, end_x, end_y, swipe_duration_ms)
except Exception:
pass
try:
analyser.swipe(start_x_base, start_y_base, end_x_base, end_y_base, swipe_duration_ms)
except Exception:
pass
# 注意:滑动后的延迟由调用方控制(如 reservation_back_swipe_delay)
# 这里不添加额外延迟,避免双重延迟
def swipe_down_back_live(analyser: Any) -> None:
"""下滑回退到上一个直播间(基础版封装)。
直接使用 ADB 内部滑动命令,不通过坐标计算。
在直播间内,向下滑动(从上往下)可以回退到上一个直播间。
采用 1080x2400 基准坐标,在屏幕中上部向下滑一段距离。
注意:这是与 swipe_up_switch_live 相反的方向。
@@ -81,10 +135,11 @@ def swipe_down_back_live(analyser: Any) -> None:
# 基准坐标(1080x2400):从上方往下滑(与上滑切换相反方向)
# 回退操作:从上往下滑动(start_y < end_y)
# 减少滑动距离:从 800 到 1300,距离约 500 像素(原来约 800 像素)
start_x_base = 540
start_y_base = 800 # 上方起始位置
end_x_base = 540
end_y_base = 1600 # 下方结束位置
end_y_base = 1300 # 下方结束位置
start_x = start_x_base * rx // 1080
end_x = end_x_base * rx // 1080
@@ -94,7 +149,7 @@ def swipe_down_back_live(analyser: Any) -> None:
try:
analyser._log_kv(
"滑动",
"swipe_down_back_live:下滑回退到上一个直播间",
"swipe_down_back_live:下滑回退到上一个直播间(使用 ADB 内部滑动)",
start_x=start_x_base,
start_y=start_y_base,
end_x=end_x_base,
@@ -110,13 +165,22 @@ def swipe_down_back_live(analyser: Any) -> None:
except Exception:
pass
# 优先调用底层 swipe,失败则静默忽略(不影响主流程)
try:
# 执行滑动操作:从 (start_x, start_y) 滑到 (end_x, end_y)
analyser.operation.swipe(device_id, start_x, start_y, end_x, end_y, 300)
except Exception:
# 直接使用 ADB 内部滑动命令
# 增加滑动持续时间(从 300ms 增加到 600ms),确保滑动更稳定
# 滑动距离约 800 像素,600ms 的速度更接近真实用户操作
swipe_duration_ms = 600
success = _adb_swipe_direct(device_id, start_x, start_y, end_x, end_y, swipe_duration_ms, analyser.operation)
if not success:
# 如果失败,尝试使用基准坐标(不缩放)
_adb_swipe_direct(device_id, start_x_base, start_y_base, end_x_base, end_y_base, swipe_duration_ms, analyser.operation)
# 如果还是失败,回退到 operation.swipe
try:
# 如果 analyser 自身提供 swipe 封装,则退回到该封装
analyser.swipe(start_x_base, start_y_base, end_x_base, end_y_base, 300)
analyser.operation.swipe(device_id, start_x, start_y, end_x, end_y, swipe_duration_ms)
except Exception:
pass
try:
analyser.swipe(start_x_base, start_y_base, end_x_base, end_y_base, swipe_duration_ms)
except Exception:
pass
# 注意:滑动后的延迟由调用方控制(如 reservation_back_swipe_delay)
# 这里不添加额外延迟,避免双重延迟
+8
View File
@@ -110,6 +110,14 @@ paddlepaddle>=2.5.0,<3.0.0
+8
View File
@@ -87,6 +87,14 @@ types-requests>=2.31.0
+8
View File
@@ -126,6 +126,14 @@ ttkbootstrap>=1.10.0
+8
View File
@@ -163,6 +163,14 @@ if __name__ == "__main__":
+18 -12
View File
@@ -1,23 +1,29 @@
{
"updated_ts": 1766803249.2134488,
"reason": "record_reservation",
"room_pos": 1,
"updated_ts": 1766819941.2713513,
"reason": "process_reservation",
"room_pos": 3,
"current_room_title": "希娜周",
"current_room_title_raw": "希娜周",
"reservations": [
{
"prize_value_yuan": 899.0,
"content": "30后开奖09Syna定制大哥水桶包616人巳参与",
"future_ts": 1766803814.320238,
"future_str": "2025-12-27 10:50:14",
"pos_seen": 1,
"content": "04后开奖04Syna定制大哥水桶包595人巳参与",
"future_ts": 1766820020.879266,
"future_str": "2025-12-27 15:20:20",
"pos_seen": 3,
"room_title": "希娜周",
"room_title_raw": "希娜周",
"created_ts": 1766803249.2030697,
"task_count": 2,
"time_text": "09:30",
"participants": 0,
"copies": 1
"created_ts": 1766819777.8944454
},
{
"prize_value_yuan": 1888.0,
"content": "46后开奖11(小北珠宝』和田玉碧玉手(圈口随机)(假一赔。镯",
"future_ts": 1766820342.793937,
"future_str": "2025-12-27 15:25:42",
"pos_seen": 0,
"room_title": "小北珠宝",
"room_title_raw": "小北珠宝",
"created_ts": 1766819678.3075242
}
]
}
+8
View File
@@ -86,6 +86,14 @@ if os.path.exists(log_file):
+8
View File
@@ -99,6 +99,14 @@ if os.path.exists(log_file):
+8
View File
@@ -232,6 +232,14 @@ pytest --pdb --pdbcls=IPython.terminal.debugger:Pdb
+8
View File
@@ -69,6 +69,14 @@ __version__ = "1.0.0"
+8
View File
@@ -58,6 +58,14 @@
+8
View File
@@ -58,6 +58,14 @@
+8
View File
@@ -148,6 +148,14 @@ python check_gpu_available.py
+8
View File
@@ -154,6 +154,14 @@
+8
View File
@@ -226,6 +226,14 @@ if __name__ == "__main__":
+8
View File
@@ -154,6 +154,14 @@
+8
View File
@@ -364,3 +364,11 @@