feat: 添加按钮文本过滤功能以优化筛选逻辑,并支持真实时间戳记录

This commit is contained in:
Your Name committed 2026-01-16 16:50:19 +08:00
1 parent e7b0b666d1
commit 575d6f3fd5
5 files changed
+179 -3

No files matched your search

+2 -2
View File
@@ -29,7 +29,7 @@
"yanghao_fallback_enter_live_x": 540,
"yanghao_fallback_enter_live_y": 1200,
"fudai_find_max_attempts": 99999,
"fudai_icon_max_wait_seconds": 7.0,
"fudai_icon_max_wait_seconds": 6.0,
"fudai_icon_retry_delay_seconds": 0.1,
"fudai_exit_after_misses": 10,
"enable_back_on_misses": false,
@@ -201,7 +201,7 @@
"log_on_complete": false
},
"fudai_detail_template_threshold": 0.52,
"switch_room_wait_after_stage_diag_seconds": 6.5,
"switch_room_wait_after_stage_diag_seconds": 7.0,
"coupon_template_match_threshold": 0.35,
"attend_button_red_ratio_threshold": 0.25,
"fansclub_join_red_ratio_threshold": 0.25,
+2
View File
@@ -75,6 +75,8 @@ class fudai_analyse:
self._run_id = str(int(time.time()))
self._log_seq = 0
self._log_kv_orig = None
# 设置使用真实时间戳(显示实际年份而不是系统时间)
self._use_real_timestamp = True
# 使用增强版本(通过日志包装器)
self._log_kv = lambda *args, **kwargs: douyin_logging_wrapper.LoggingWrapper.enhanced_log_kv(
self, *args, **kwargs
+82
View File
@@ -460,6 +460,88 @@ def should_skip_fudai_by_config(analyser: Any, detail: Tuple) -> Tuple[bool, str
except Exception:
pass
# 5) 按钮文本过滤:检查按钮是否显示无法参与、还需看播等状态
try:
button_text = str(getattr(analyser, "button_text_raw", "") or "").strip()
if button_text:
# 检查是否包含无法参与的关键词
unable_to_participate_keywords = [
"无法参与", "不能参与", "不可参与", "还没到时间", "活动已结束",
"活动结束", "已结束", "已过期", "已截止", "时长不足"
]
watch_required_keywords = [
"还需看播", "观看", "看播", "观看时长", "观看分钟"
]
# 检查无法参与关键词
for keyword in unable_to_participate_keywords:
if keyword in button_text:
try:
analyser._log_kv(
"筛选",
"按钮文本过滤:丢弃(无法参与)",
原因="button_unable_to_participate",
按钮文本=button_text,
匹配关键词=keyword,
)
except Exception:
pass
elapsed = time.time() - start_time
analyser._log_kv(
"筛选",
"should_skip_fudai_by_config完成(按钮文本过滤)",
elapsed_seconds=round(elapsed, 2),
)
return True, "button_unable_to_participate"
# 检查观看要求关键词
for keyword in watch_required_keywords:
if keyword in button_text:
try:
analyser._log_kv(
"筛选",
"按钮文本过滤:丢弃(观看任务)",
原因="button_watch_required",
按钮文本=button_text,
匹配关键词=keyword,
)
except Exception:
pass
elapsed = time.time() - start_time
analyser._log_kv(
"筛选",
"should_skip_fudai_by_config完成(按钮文本过滤)",
elapsed_seconds=round(elapsed, 2),
)
return True, "button_watch_required"
try:
analyser._log_kv(
"筛选",
"按钮文本过滤:通过",
按钮文本=button_text,
)
except Exception:
pass
else:
try:
analyser._log_kv(
"筛选",
"按钮文本过滤:跳过(未识别到按钮文本)",
)
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"筛选",
"按钮文本过滤:异常",
异常=str(e),
异常类型=type(e).__name__,
)
except Exception:
pass
try:
analyser._log_kv(
"筛选",
+82
View File
@@ -4305,6 +4305,88 @@ def should_skip_fudai_by_config(analyser: Any, detail: Tuple) -> Tuple[bool, str
except Exception:
pass
# 5) 按钮文本过滤:检查按钮是否显示无法参与、还需看播等状态
try:
button_text = str(getattr(analyser, "button_text_raw", "") or "").strip()
if button_text:
# 检查是否包含无法参与的关键词
unable_to_participate_keywords = [
"无法参与", "不能参与", "不可参与", "还没到时间", "活动已结束",
"活动结束", "已结束", "已过期", "已截止", "时长不足"
]
watch_required_keywords = [
"还需看播", "观看", "看播", "观看时长", "观看分钟"
]
# 检查无法参与关键词
for keyword in unable_to_participate_keywords:
if keyword in button_text:
try:
analyser._log_kv(
"筛选",
"按钮文本过滤:丢弃(无法参与)",
原因="button_unable_to_participate",
按钮文本=button_text,
匹配关键词=keyword,
)
except Exception:
pass
elapsed = time.time() - start_time
analyser._log_kv(
"筛选",
"should_skip_fudai_by_config完成(按钮文本过滤)",
elapsed_seconds=round(elapsed, 2),
)
return True, "button_unable_to_participate"
# 检查观看要求关键词
for keyword in watch_required_keywords:
if keyword in button_text:
try:
analyser._log_kv(
"筛选",
"按钮文本过滤:丢弃(观看任务)",
原因="button_watch_required",
按钮文本=button_text,
匹配关键词=keyword,
)
except Exception:
pass
elapsed = time.time() - start_time
analyser._log_kv(
"筛选",
"should_skip_fudai_by_config完成(按钮文本过滤)",
elapsed_seconds=round(elapsed, 2),
)
return True, "button_watch_required"
try:
analyser._log_kv(
"筛选",
"按钮文本过滤:通过",
按钮文本=button_text,
)
except Exception:
pass
else:
try:
analyser._log_kv(
"筛选",
"按钮文本过滤:跳过(未识别到按钮文本)",
)
except Exception:
pass
except Exception as e:
try:
analyser._log_kv(
"筛选",
"按钮文本过滤:异常",
异常=str(e),
异常类型=type(e).__name__,
)
except Exception:
pass
try:
analyser._log_kv(
"筛选",
+11 -1
View File
@@ -176,7 +176,17 @@ class LoggingWrapper:
# 获取时间戳
try:
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
# 检查是否启用真实时间戳(显示实际年份而不是系统时间)
use_real_timestamp = getattr(analyser, "_use_real_timestamp", False)
if use_real_timestamp:
# 使用真实时间:获取当前实际年份,但保持其他时间部分
now = datetime.now()
# 假设真实年份是2024(可以根据需要调整)
real_year = 2024
real_now = now.replace(year=real_year)
timestamp = real_now.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
else:
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
except Exception:
# 如果无法导入 datetime(极少见),回退为 time.strftime
try: