chore: remove generated reports and logs from repo, update .gitignore
This commit is contained in:
1 parent
ee0511e327
commit
488f6a1fdf
15 files changed
+137
-48
No files matched your search
+14
@@ -9,6 +9,20 @@ __pycache__/
|
||||
*.log
|
||||
pic/
|
||||
|
||||
# Tools generated reports
|
||||
tools/coords_report.csv
|
||||
tools/coords_report_head.csv
|
||||
tools/coords_report_expanded.csv
|
||||
|
||||
# Tools sample/ocr artifacts
|
||||
tools/ocr_failures*
|
||||
tools/samples/
|
||||
|
||||
# Logs (keep local logs out of VCS)
|
||||
logs/
|
||||
*.log*
|
||||
logs/*.gz
|
||||
|
||||
# Code analysis reports
|
||||
pylint_report.txt
|
||||
pyright_report.txt
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"needswitch": true,
|
||||
"needswitch": false,
|
||||
"infinite_loop_enabled": true,
|
||||
"wait_minutes": 5,
|
||||
"min_prize_value_yuan": 200.0,
|
||||
@@ -149,4 +149,4 @@
|
||||
"fansclub_auto_join_wait_seconds": 5.0,
|
||||
"fansclub_manual_wait_seconds": 3.0,
|
||||
"enable_streaming_screenshot": false
|
||||
}
|
||||
}
|
||||
@@ -137,6 +137,55 @@ def find_and_open_fudai_detail(
|
||||
"find_and_open_fudai_detail完成(未找到福袋)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
# 未找到福袋:增加连续未找到计数(由 analyser 维护),以便触发退出直播间动作
|
||||
try:
|
||||
cur = int(getattr(analyser, "_consecutive_no_fudai_count", 0) or 0)
|
||||
cur += 1
|
||||
setattr(analyser, "_consecutive_no_fudai_count", cur)
|
||||
threshold = int(getattr(analyser, "fudai_exit_after_misses", 0) or 0) or None
|
||||
if threshold is None or threshold <= 0:
|
||||
# 如果未配置阈值,则尝试读取配置属性(兼容性)
|
||||
try:
|
||||
import json
|
||||
|
||||
cfg_path = path_config.get_config_path()
|
||||
if cfg_path and os.path.exists(cfg_path):
|
||||
with open(cfg_path, "r", encoding="utf-8") as f:
|
||||
cfg = json.load(f)
|
||||
threshold = int(cfg.get("fudai_exit_after_misses", 30) or 30)
|
||||
except Exception:
|
||||
threshold = 30
|
||||
# 如果计数达到阈值,执行返回键退出直播间并重置计数
|
||||
if threshold and cur >= threshold:
|
||||
try:
|
||||
analyser._log_kv(
|
||||
"流程",
|
||||
"连续未找到福袋达到阈值:按返回键退出直播间",
|
||||
consecutive_no_fudai=cur,
|
||||
threshold=threshold,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
analyser.operation.click_back(analyser.device_id)
|
||||
except Exception:
|
||||
try:
|
||||
# 兜底:使用通用 click 返回坐标
|
||||
rx = int(getattr(analyser, "resolution_ratio_x", 1080) or 1080)
|
||||
ry = int(getattr(analyser, "resolution_ratio_y", 2400) or 2400)
|
||||
back_x = int(50 * rx / 1080)
|
||||
back_y = int(50 * ry / 2400)
|
||||
analyser.operation.click(analyser.device_id, back_x, back_y)
|
||||
except Exception:
|
||||
pass
|
||||
# 重置计数,避免重复触发
|
||||
try:
|
||||
setattr(analyser, "_consecutive_no_fudai_count", 0)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
# 容错:如果处理计数或配置读取出错,忽略并继续返回 False
|
||||
pass
|
||||
return False
|
||||
|
||||
# 点击坐标:用检测到的 X,加一个固定基准 Y(图标所在高度)
|
||||
@@ -277,6 +326,12 @@ def find_and_open_fudai_detail(
|
||||
analyser._last_fudai_detail_tuple = None
|
||||
except Exception:
|
||||
pass
|
||||
# 成功打开福袋详情:重置连续未找到计数
|
||||
try:
|
||||
setattr(analyser, "_consecutive_no_fudai_count", 0)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
elapsed = time.time() - func_start_time
|
||||
analyser._log_kv(
|
||||
"流程",
|
||||
|
||||
@@ -227,7 +227,11 @@ class MainLogicMixin(BaseFudaiMixin):
|
||||
opened = douyin_flow_control.find_and_open_fudai_detail(self, room_pos_ref)
|
||||
|
||||
if opened:
|
||||
# 成功打开福袋详情,调用参与逻辑
|
||||
# 成功打开福袋详情:重置连续未找到计数并调用参与逻辑
|
||||
try:
|
||||
setattr(self, "_consecutive_no_fudai_count", 0)
|
||||
except Exception:
|
||||
pass
|
||||
self._handle_in_fudai_detail()
|
||||
self._safe_log("流程", "_handle_live_room_has_or_not_fudai:成功处理福袋")
|
||||
else:
|
||||
|
||||
@@ -124,6 +124,7 @@ class ReservationHandler:
|
||||
analyser._log_kv( # type: ignore[attr-defined]
|
||||
"预约",
|
||||
"[预约] _find_room_pos_by_title:在映射表中找到匹配位置",
|
||||
log_type="OP",
|
||||
target_title=target_title[:50] if target_title else "",
|
||||
found_pos=best_match_pos,
|
||||
match_score=round(best_match_score, 3),
|
||||
@@ -202,17 +203,20 @@ class ReservationHandler:
|
||||
room_title,
|
||||
room_title_raw,
|
||||
)
|
||||
try:
|
||||
analyser._log_kv( # type: ignore[attr-defined]
|
||||
"预约",
|
||||
"[预约] 记录直播间标题和位置到运行时映射表",
|
||||
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(analyser._room_pos_to_title_map),
|
||||
)
|
||||
try:
|
||||
analyser._log_kv( # type: ignore[attr-defined]
|
||||
"预约",
|
||||
"[预约] 记录直播间标题和位置到运行时映射表",
|
||||
log_type="OP",
|
||||
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(analyser._room_pos_to_title_map),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
@@ -227,6 +231,7 @@ class ReservationHandler:
|
||||
analyser._log_kv( # type: ignore[attr-defined]
|
||||
"预约",
|
||||
"[预约] 更新直播间标题和位置到运行时映射表",
|
||||
log_type="OP",
|
||||
room_pos=room_pos,
|
||||
old_room_title=old_title[:50] if old_title else "",
|
||||
new_room_title=room_title[:50] if room_title else "",
|
||||
@@ -251,6 +256,7 @@ class ReservationHandler:
|
||||
analyser._log_kv( # type: ignore[attr-defined]
|
||||
"预约",
|
||||
"[预约] 使用缓存标题记录直播间位置到运行时映射表",
|
||||
log_type="OP",
|
||||
room_pos=room_pos,
|
||||
room_title=room_title[:50] if room_title else "",
|
||||
error=str(e),
|
||||
|
||||
@@ -185,6 +185,7 @@ def add_reservation_core_logic(
|
||||
analyser._log_kv(
|
||||
"预约",
|
||||
"[预约] add_reservation_core_logic 函数入口",
|
||||
log_type="OP",
|
||||
future_ts=int(ft) if ft > 0 else 0,
|
||||
future_str=ft_str,
|
||||
prize_value_yuan=prize_value,
|
||||
@@ -204,7 +205,7 @@ def add_reservation_core_logic(
|
||||
)
|
||||
else:
|
||||
try:
|
||||
analyser._log_kv("预约", "[预约] 记录函数入口日志失败", error=str(e))
|
||||
analyser._log_kv("预约", "[预约] 记录函数入口日志失败", log_type="ERR", error=str(e))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -284,7 +285,8 @@ def add_reservation_core_logic(
|
||||
if analyser:
|
||||
analyser._log_kv(
|
||||
"预约",
|
||||
"[预约] 通过直播间名称和价值匹配识别为重复预约",
|
||||
"[预约] 通过直播间名称和价值匹配识别为重复预约",
|
||||
log_type="OP",
|
||||
room_title_normalized=room_title_normalized,
|
||||
time_diff=round(time_diff, 2),
|
||||
prize_value_yuan=prize_value,
|
||||
@@ -299,7 +301,8 @@ def add_reservation_core_logic(
|
||||
if analyser:
|
||||
analyser._log_kv(
|
||||
"预约",
|
||||
"[预约] 通过相似度匹配识别为重复预约",
|
||||
"[预约] 通过相似度匹配识别为重复预约",
|
||||
log_type="OP",
|
||||
room_title_normalized=room_title_normalized,
|
||||
r_room_title_normalized=r_room_title_normalized,
|
||||
time_diff=round(time_diff, 2),
|
||||
@@ -447,6 +450,7 @@ def add_reservation_core_logic(
|
||||
analyser._log_kv(
|
||||
"预约",
|
||||
"[预约] add_reservation_core_logic 完成",
|
||||
log_type="OP",
|
||||
queue_len_after=len(reservations),
|
||||
queue_full=queue_full,
|
||||
elapsed_seconds=round(elapsed, 3),
|
||||
@@ -462,7 +466,7 @@ def add_reservation_core_logic(
|
||||
)
|
||||
else:
|
||||
try:
|
||||
analyser._log_kv("预约", "[预约] 记录函数完成日志失败", error=str(e))
|
||||
analyser._log_kv("预约", "[预约] 记录函数完成日志失败", log_type="ERR", error=str(e))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -481,6 +485,7 @@ def validate_back_to_reservation(
|
||||
analyser._log_kv(
|
||||
"预约",
|
||||
"[预约] validate_back_to_reservation",
|
||||
log_type="OP",
|
||||
count=len(reservations),
|
||||
now_ts=int(now_ts),
|
||||
)
|
||||
|
||||
@@ -188,6 +188,7 @@ def validate_back_to_reservation(
|
||||
analyser._log_kv(
|
||||
"预约",
|
||||
"[预约] validate_back_to_reservation:函数入口",
|
||||
log_type="OP",
|
||||
target_pos=int(item.get("pos_seen", 0)),
|
||||
target_room_title=str(item.get("room_title", ""))[:50],
|
||||
quick=quick,
|
||||
@@ -202,7 +203,7 @@ def validate_back_to_reservation(
|
||||
verify_enabled = bool(getattr(analyser, "reservation_back_verify_enabled", True))
|
||||
if not verify_enabled:
|
||||
try:
|
||||
analyser._log_kv("预约", "回退校验已被禁用:跳过校验", level="DEBUG")
|
||||
analyser._log_kv("预约", "回退校验已被禁用:跳过校验", log_type="DEBUG", level="DEBUG")
|
||||
except Exception:
|
||||
pass
|
||||
return True, None
|
||||
@@ -306,33 +307,27 @@ def validate_back_to_reservation(
|
||||
current_title, current_title_raw = douyin_fudai_detail.read_live_room_title_core(
|
||||
analyser, y_pianyi_val
|
||||
)
|
||||
# 更新 analyser 的属性
|
||||
try:
|
||||
analyser.current_room_title = current_title
|
||||
analyser.current_room_title_raw = current_title_raw
|
||||
# 计算预期标题与当前标题的相似度
|
||||
ratio = 0.0
|
||||
if current_title and expected_title:
|
||||
import difflib as _difflib
|
||||
|
||||
ratio = _difflib.SequenceMatcher(None, expected_title, current_title).ratio()
|
||||
|
||||
analyser._log_kv(
|
||||
"预约",
|
||||
"回退校验:直播间名对比",
|
||||
log_type="DEBUG",
|
||||
room_title_expected=expected_title,
|
||||
room_title_current=current_title,
|
||||
room_title_raw_expected=expected_title_raw,
|
||||
room_title_raw_current=current_title_raw,
|
||||
room_title_ratio=round(ratio, 3),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if current_title:
|
||||
ratio = 0.0
|
||||
try:
|
||||
ratio = float(difflib.SequenceMatcher(None, expected_title, current_title).ratio())
|
||||
except Exception:
|
||||
ratio = 0.0
|
||||
|
||||
try:
|
||||
analyser._log_kv(
|
||||
"预约",
|
||||
"回退校验:直播间名对比",
|
||||
room_title_expected=expected_title,
|
||||
room_title_current=current_title,
|
||||
room_title_raw_expected=expected_title_raw,
|
||||
room_title_raw_current=current_title_raw,
|
||||
room_title_ratio=round(ratio, 3),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 强不匹配:根据映射表找到正确位置并回退
|
||||
if current_title and (expected_title not in current_title) and (current_title not in expected_title) and ratio < 0.45:
|
||||
try:
|
||||
|
||||
@@ -43,6 +43,7 @@ class HelperFunctions:
|
||||
analyser._log_kv( # type: ignore[attr-defined, reportPrivateUsage]
|
||||
"操作",
|
||||
"点击操作",
|
||||
log_type="OP",
|
||||
x=int(x),
|
||||
y=int(y),
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
@@ -278,12 +279,13 @@ class HelperFunctions:
|
||||
try:
|
||||
HelperFunctions.click(analyser, btn_x, btn_y)
|
||||
analyser._log_kv( # type: ignore[attr-defined, reportPrivateUsage]
|
||||
"开奖结果", "已通过OCR执行点击", x=btn_x, y=btn_y
|
||||
"开奖结果", "已通过OCR执行点击", log_type="OP", x=btn_x, y=btn_y
|
||||
)
|
||||
except Exception as e:
|
||||
analyser._log_kv( # type: ignore[attr-defined, reportPrivateUsage]
|
||||
"开奖结果",
|
||||
"OCR点击执行失败,继续后续处理",
|
||||
log_type="ERR",
|
||||
x=btn_x,
|
||||
y=btn_y,
|
||||
error=str(e),
|
||||
@@ -306,13 +308,14 @@ class HelperFunctions:
|
||||
|
||||
if needswitch:
|
||||
analyser._log_kv( # type: ignore[attr-defined, reportPrivateUsage]
|
||||
"开奖结果", "处理完开奖结果,切换直播间找新福袋"
|
||||
"开奖结果", "处理完开奖结果,切换直播间找新福袋", log_type="OP"
|
||||
)
|
||||
analyser.swipe_up_to_next_live() # type: ignore[attr-defined]
|
||||
else:
|
||||
analyser._log_kv( # type: ignore[attr-defined, reportPrivateUsage]
|
||||
"开奖结果",
|
||||
"处理完开奖结果,未启用切换,继续在当前直播间",
|
||||
log_type="OP",
|
||||
)
|
||||
|
||||
elif result_type == "立即领取奖品":
|
||||
@@ -346,17 +349,17 @@ class HelperFunctions:
|
||||
shutil.copy(src, dst)
|
||||
|
||||
analyser._log_kv( # type: ignore[attr-defined, reportPrivateUsage]
|
||||
"开奖结果", "已保存立即领取奖品截图", path=dst
|
||||
"开奖结果", "已保存立即领取奖品截图", log_type="SCREENSHOT", path=dst
|
||||
)
|
||||
except Exception as e:
|
||||
analyser._log_kv( # type: ignore[attr-defined, reportPrivateUsage]
|
||||
"开奖结果", "保存截图失败", error=str(e)
|
||||
"开奖结果", "保存截图失败", log_type="ERR", error=str(e)
|
||||
)
|
||||
|
||||
# 点击返回键
|
||||
analyser.operation.click_back(analyser.device_id)
|
||||
analyser._log_kv( # type: ignore[attr-defined, reportPrivateUsage]
|
||||
"开奖结果", "点击返回键关闭开奖结果"
|
||||
"开奖结果", "点击返回键关闭开奖结果", log_type="OP"
|
||||
)
|
||||
analyser.operation.delay(0.5)
|
||||
|
||||
@@ -368,13 +371,14 @@ class HelperFunctions:
|
||||
|
||||
if needswitch:
|
||||
analyser._log_kv( # type: ignore[attr-defined, reportPrivateUsage]
|
||||
"开奖结果", "处理完开奖结果,切换直播间找新福袋"
|
||||
"开奖结果", "处理完开奖结果,切换直播间找新福袋", log_type="OP"
|
||||
)
|
||||
analyser.swipe_up_to_next_live() # type: ignore[attr-defined]
|
||||
else:
|
||||
analyser._log_kv( # type: ignore[attr-defined, reportPrivateUsage]
|
||||
"开奖结果",
|
||||
"处理完开奖结果,未启用切换,继续在当前直播间",
|
||||
log_type="OP",
|
||||
)
|
||||
except Exception as e:
|
||||
analyser._log_kv( # type: ignore[attr-defined, reportPrivateUsage]
|
||||
@@ -396,6 +400,7 @@ class HelperFunctions:
|
||||
analyser._log_kv( # type: ignore[attr-defined, reportPrivateUsage]
|
||||
"流程",
|
||||
"_handle_lottery_result_by_ocr完成",
|
||||
log_type="PERF",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
result_type=result_type,
|
||||
)
|
||||
|
||||
@@ -1595,6 +1595,10 @@ def main():
|
||||
fudai_disable_content_recognition_var.set(
|
||||
bool(cfg.get("fudai_disable_content_recognition", False))
|
||||
)
|
||||
try:
|
||||
fudai_exit_after_misses_var.set(int(cfg.get("fudai_exit_after_misses", 30) or 30))
|
||||
except Exception:
|
||||
fudai_exit_after_misses_var.set(30)
|
||||
switch_room_wait_after_stage_diag_seconds_var.set(
|
||||
float(cfg.get("switch_room_wait_after_stage_diag_seconds", 7.0) or 7.0)
|
||||
)
|
||||
@@ -1811,6 +1815,7 @@ def main():
|
||||
cfg2["fudai_click_wait_seconds"] = float(
|
||||
fudai_click_wait_seconds_var.get() or 2.0
|
||||
)
|
||||
cfg2["fudai_exit_after_misses"] = int(fudai_exit_after_misses_var.get() or 30)
|
||||
cfg2["fudai_disable_content_recognition"] = bool(
|
||||
fudai_disable_content_recognition_var.get()
|
||||
)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user