refactor: 删除 fudai_core 中重复的 check_contain
check_contain 在 fudai_filter.py 中已有完全相同的实现。 通过顶部 import 直接复用,删除 douyin_fudai_core.py 中的副本。 文件行数:6250 -> 6206(减 44 行) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e38640eb63
commit
7d834d316f
1 file changed
+3
-47
@@ -15,6 +15,7 @@ from douyin.core import path_config
|
||||
from douyin.fudai.core.fudai_filter import (
|
||||
is_watch_task_fudai,
|
||||
_is_short_countdown_text,
|
||||
check_contain,
|
||||
)
|
||||
from douyin.fudai.core.fudai_result_checker import (
|
||||
check_lucky_draw_result,
|
||||
@@ -2130,53 +2131,8 @@ def get_fudai_contain(analyser, renwu: int = 2) -> Tuple[str, str, int, int, flo
|
||||
return fudai_content_text, time_text, participants, copies, prize_value_yuan
|
||||
|
||||
|
||||
def check_contain(analyser, contains: str = "") -> bool:
|
||||
"""检查福袋内容是否命中“黑名单”关键词(只保留黑名单逻辑,不再使用白名单)。
|
||||
|
||||
返回值语义(调整后):
|
||||
- True : “建议丢弃”(内容命中黑名单 contains_not_want)
|
||||
- False : “可以保留”(未命中黑名单)
|
||||
"""
|
||||
|
||||
# 以下抑制为静态检查方便添加:
|
||||
# - W0212: protected-access(许多地方访问分析器/底层对象的受保护属性,运行时可用)
|
||||
# - W0718: broad-exception-caught(代码中大量使用 broad except 用于鲁棒性)
|
||||
# 这些抑制只影响静态检查,不改变运行时行为。
|
||||
# pylint: disable=W0212,W0718
|
||||
try:
|
||||
for contain in getattr(analyser, "contains_not_want", []) or []:
|
||||
if contain and contain in (contains or ""):
|
||||
try:
|
||||
analyser._log_kv(
|
||||
"筛选",
|
||||
"福袋内容命中黑名单,将丢弃",
|
||||
keyword=contain,
|
||||
contains=contains[:80] if contains else "",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
return True
|
||||
|
||||
try:
|
||||
analyser._log_kv(
|
||||
"筛选",
|
||||
"福袋内容未命中黑名单,保留",
|
||||
contains=contains[:80] if contains else "",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
return False
|
||||
except Exception:
|
||||
# 容错:异常时不过滤
|
||||
try:
|
||||
analyser._log_kv(
|
||||
"筛选",
|
||||
"check_contain 异常,默认保留",
|
||||
contains=contains[:80] if contains else "",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
return False
|
||||
# check_contain 已迁移到 douyin.fudai.core.fudai_filter(顶部导入)。
|
||||
# 此处保留模块级名称以兼容历史 from douyin_fudai_core import check_contain。
|
||||
|
||||
|
||||
def attend_choujiang(analyser) -> bool:
|
||||
|
||||
Reference in new issue
Block a user