2 Commits
Author SHA1 Message Date
Your Name 8e8a14cf69 build: allow reusing pyinstaller cache 2026-06-24 03:47:38 +08:00
Your Name 164f76658c fix reservation fansclub prejoin timing 2026-06-24 02:20:20 +08:00
5 changed files with 79 additions and 5 deletions

No files matched your search

@@ -32,10 +32,13 @@ def _scaled_point(analyser: Any, point: tuple[int, int]) -> tuple[int, int]:
def _fast_delay(analyser: Any, attr_name: str, default_seconds: float) -> None:
try:
seconds = float(getattr(analyser, attr_name, default_seconds) or default_seconds)
raw = getattr(analyser, attr_name, default_seconds)
if not isinstance(raw, (int, float, str)):
raw = default_seconds
seconds = float(raw or default_seconds)
except Exception:
seconds = default_seconds
seconds = max(0.0, min(seconds, 1.2))
seconds = max(0.0, min(seconds, 3.0))
try:
analyser.operation.delay(seconds)
except Exception:
@@ -74,7 +77,7 @@ def handle_reservation_prejoin_fansclub(
pass
return False
_fast_delay(analyser, "reservation_prejoin_fansclub_participate_wait_seconds", 0.6)
_fast_delay(analyser, "reservation_prejoin_fansclub_participate_wait_seconds", 1.2)
click_point = FANSCLUB_JOIN_CLICK
click_x, click_y = _scaled_point(analyser, click_point)
@@ -118,7 +121,7 @@ def handle_reservation_prejoin_fansclub(
pass
return False
_fast_delay(analyser, "reservation_prejoin_fansclub_confirm_wait_seconds", 0.8)
_fast_delay(analyser, "reservation_prejoin_fansclub_confirm_wait_seconds", 1.6)
try:
analyser.click(*DETAIL_OUTSIDE_CLICK)
@@ -33,6 +33,10 @@ _DIRECT_ATTEND_ACTIONABLE_BUTTON_TEXT_SNIPPETS = (
"发表",
"一键",
)
_DIRECT_ATTEND_FANSCLUB_TEXT_SNIPPETS = (
"粉丝团",
"关注主播",
)
# 错误处理工具占位(与原文件保持兼容降级)
try:
@@ -321,6 +325,33 @@ def _reservation_button_fallback_is_actionable(analyser: Any, item: Dict[str, An
return False, button_text, button_status
def _normalize_direct_button_text(text: str) -> str:
return "".join(ch for ch in str(text or "") if ch not in " \t\r\n·。.,,、::||-_")
def _looks_like_fansclub_button_text(button_text: str, button_status: str = "") -> bool:
joined = _normalize_direct_button_text(button_text) + _normalize_direct_button_text(
button_status
)
if not joined:
return False
if "粉丝团" in joined:
return True
if "关注主播" in joined and ("加入" in joined or "加人" in joined):
return True
if "需要加入粉丝" in joined:
return True
return False
def _reservation_may_need_fansclub_flow(item: Dict[str, Any]) -> bool:
button_text = str(item.get("button_text") or item.get("button_text_raw") or "")
button_status = str(item.get("button_status") or "")
if bool(item.get("prejoined_fansclub_before_reservation")):
return True
return _looks_like_fansclub_button_text(button_text, button_status)
def _ocr_current_attend_button_if_actionable(analyser: Any, item: Dict[str, Any]) -> tuple[bool, str, str]:
try:
from douyin.fudai.core.coords import get_fudai_detail_profile
@@ -817,6 +848,29 @@ def handle_reservation_direct_attend(analyser: Any) -> None:
except Exception:
pass
if has_button and _reservation_may_need_fansclub_flow(first_reservation):
current_ok, current_button_text, current_button_status = (
_ocr_current_attend_button_if_actionable(analyser, first_reservation)
)
if current_button_text and _looks_like_fansclub_button_text(
current_button_text,
current_button_status,
):
try:
analyser._log_kv(
"预约",
"[预约] 预约直参检测到当前仍是粉丝团任务按钮,交给详情页正常流程",
button_info=button_info,
button_text=current_button_text[:80],
button_status=current_button_status,
ocr_actionable=bool(current_ok),
reason="direct_attend_fansclub_button_semantic_guard",
)
except Exception:
pass
analyser._handle_in_fudai_detail() # type: ignore[attr-defined]
return
if not has_button:
fallback_ok, fallback_button_text, fallback_button_status = (
_reservation_button_fallback_is_actionable(analyser, first_reservation)
+6
View File
@@ -27,6 +27,12 @@ powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_
该流程会生成 `build\cythonized-src\`,其中核心模块以 `.pyd` 形式存在。该目录是中间产物,不要直接分发;最终仍然只分发 `dist\DouyinGuaji-<version>\` 或 Inno 生成的安装包。
如果只是小更新、想复用 PyInstaller 缓存来加快打包,可以额外加 `-ReuseCache`。注意:改到 `douyin/fudai`、`douyin/reservation`、`douyin/detection` 或 `douyin/stage` 时,Cython 核心仍会重新编译;`-ReuseCache` 主要复用 PyInstaller 的分析/收集缓存。
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_windows.ps1 -SkipInstall -ReuseCache
```
如果需要继续使用旧的 PyArmor 路线,可额外加 `-UsePyArmor`。注意:PyArmor 试用版会在混淆文件头部留下 trial 标记,正式分发前建议购买/配置正式授权后重新打包。若 PyArmor 授权不可用,旧路线会失败并停止。
仅本机开发调试需要生成明文包时,才显式加 `-NoCythonForDevOnly`:
+4 -1
View File
@@ -7,6 +7,7 @@ param(
[switch]$PackExe,
[switch]$PackExeForce,
[switch]$IncludeLicense,
[switch]$ReuseCache,
[string]$UpxDir = ""
)
@@ -61,7 +62,6 @@ if ($UsePyArmor -and -not $NoObfuscateForDevOnly) {
}
$CommonArgs = @(
"--clean",
"--noconfirm",
"--distpath", $DistRoot,
"--workpath", (Join-Path $Root "build\pyinstaller"),
@@ -72,6 +72,9 @@ $CommonArgs = @(
"--hidden-import", "logging.handlers",
"--hidden-import", "cryptography.hazmat.primitives.serialization"
)
if (-not $ReuseCache) {
$CommonArgs = @("--clean") + $CommonArgs
}
$GuiArgs = @(
"--collect-submodules", "gui"
+8
View File
@@ -167,3 +167,11 @@ class TestReservationPrejoinFansclub:
delay_args = [c.args[0] for c in a.operation.delay.call_args_list]
assert delay_args == [0.2, 0.3]
def test_fast_prejoin_default_delays_wait_for_join_page_and_result(self):
a = _mk_analyser(auto_join_fansclub=True)
handle_reservation_prejoin_fansclub(a, "加入直播粉丝团并关注主播")
delay_args = [c.args[0] for c in a.operation.delay.call_args_list]
assert delay_args == [1.2, 1.6]