feat: 优化代码格式,增加换行以提高可读性
This commit is contained in:
1 parent
54f3b35a26
commit
245e721c94
4 files changed
+62
-24
No files matched your search
@@ -310,7 +310,9 @@ class fudai_analyse:
|
||||
self._just_switched_room: bool = False # 是否刚刚切换了直播间
|
||||
|
||||
# 高价值房间重访相关状态
|
||||
self._last_high_value_revisit_ts: float = time.time() # 最后一次重访时间戳,初始化为当前时间避免启动后立即重访
|
||||
self._last_high_value_revisit_ts: float = (
|
||||
time.time()
|
||||
) # 最后一次重访时间戳,初始化为当前时间避免启动后立即重访
|
||||
self._current_run_revisit_count: int = 0 # 本次运行的重访次数
|
||||
self._current_run_high_value_rooms: list[dict[str, Any]] = (
|
||||
[]
|
||||
@@ -1605,7 +1607,9 @@ class fudai_analyse:
|
||||
|
||||
def _seek_reservation_room(item: dict) -> bool:
|
||||
try:
|
||||
return bool(self._seek_reservation_room(item, operation_type="预约"))
|
||||
return bool(
|
||||
self._seek_reservation_room(item, operation_type="预约")
|
||||
)
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
@@ -2047,8 +2051,12 @@ class fudai_analyse:
|
||||
analyser=self,
|
||||
revisit_enabled=revisit_enabled,
|
||||
only_current_run=only_current_run,
|
||||
min_interval_seconds=getattr(self, "high_value_room_revisit_min_interval_seconds", 300),
|
||||
max_revisit_per_run=getattr(self, "high_value_room_revisit_max_per_run", 5),
|
||||
min_interval_seconds=getattr(
|
||||
self, "high_value_room_revisit_min_interval_seconds", 300
|
||||
),
|
||||
max_revisit_per_run=getattr(
|
||||
self, "high_value_room_revisit_max_per_run", 5
|
||||
),
|
||||
)
|
||||
|
||||
if should_revisit:
|
||||
@@ -2056,8 +2064,12 @@ class fudai_analyse:
|
||||
candidates = douyin_high_value_room.get_revisit_candidates(
|
||||
analyser=self,
|
||||
only_current_run=only_current_run,
|
||||
min_prize_value=getattr(self, "high_value_room_revisit_min_prize_value", 0.0),
|
||||
max_age_days=getattr(self, "high_value_room_revisit_max_age_days", 30),
|
||||
min_prize_value=getattr(
|
||||
self, "high_value_room_revisit_min_prize_value", 0.0
|
||||
),
|
||||
max_age_days=getattr(
|
||||
self, "high_value_room_revisit_max_age_days", 30
|
||||
),
|
||||
)
|
||||
|
||||
if candidates:
|
||||
@@ -2523,7 +2535,9 @@ class fudai_analyse:
|
||||
"""
|
||||
return douyin_swipe_handler.SwipeHandler.maybe_reset_after_swipes(self)
|
||||
|
||||
def _seek_reservation_room(self, item: dict[str, Any], operation_type: str = "预约") -> bool:
|
||||
def _seek_reservation_room(
|
||||
self, item: dict[str, Any], operation_type: str = "预约"
|
||||
) -> bool:
|
||||
"""根据预约记录里的 pos_seen 与当前 room_pos 进行回退,靠近目标直播间。
|
||||
|
||||
说明:
|
||||
@@ -2602,7 +2616,9 @@ class fudai_analyse:
|
||||
self._last_fudai_detail_tuple = detail
|
||||
# 设置当前福袋的 content(使用 cast 帮助静态分析)
|
||||
detail_t: Tuple[Any, ...] = tuple(detail)
|
||||
self._current_fudai_content = detail_t[0] if len(detail_t) > 0 else ""
|
||||
self._current_fudai_content = (
|
||||
detail_t[0] if len(detail_t) > 0 else ""
|
||||
)
|
||||
else:
|
||||
# 使用第一次保存的详情数据,设置当前福袋的倒计时信息
|
||||
try:
|
||||
@@ -3282,7 +3298,9 @@ class fudai_analyse:
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
join_result = douyin_fudai_core.basic_join_decision(self, detail, (skip, skip_reason))
|
||||
join_result = douyin_fudai_core.basic_join_decision(
|
||||
self, detail, (skip, skip_reason)
|
||||
)
|
||||
|
||||
# 检查是否参与成功:如果 _last_successful_attend_ts 刚刚更新,说明参与成功
|
||||
attend_after_ts = getattr(self, "_last_successful_attend_ts", 0.0) or 0.0
|
||||
|
||||
@@ -207,17 +207,19 @@ def attend_choujiang(analyser) -> bool:
|
||||
analyser._log_kv("参与", "关闭福袋详情", action="关闭详情")
|
||||
return True
|
||||
elif attend_button_text and (
|
||||
("活动已结束" in attend_button_text) or
|
||||
("活动己结束" in attend_button_text) or
|
||||
("福袋超时" in attend_button_text) or
|
||||
("活动超时" in attend_button_text) or
|
||||
("已超时" in attend_button_text)
|
||||
("活动已结束" in attend_button_text)
|
||||
or ("活动己结束" in attend_button_text)
|
||||
or ("福袋超时" in attend_button_text)
|
||||
or ("活动超时" in attend_button_text)
|
||||
or ("已超时" in attend_button_text)
|
||||
):
|
||||
# 活动结束/福袋超时:按一次返回键退出详情
|
||||
analyser.last_attend_fail_reason = "activity_ended"
|
||||
try:
|
||||
analyser._log_kv(
|
||||
"参与", "活动已结束/福袋超时:按返回键退出详情", result="activity_ended"
|
||||
"参与",
|
||||
"活动已结束/福袋超时:按返回键退出详情",
|
||||
result="activity_ended",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -5406,7 +5406,7 @@ def basic_join_decision(
|
||||
r_ft = float(r.get("future_ts") or 0.0)
|
||||
r_content = str(r.get("content") or "")
|
||||
r_room_title = str(r.get("room_title") or "")
|
||||
|
||||
|
||||
# 检查是否是同一个福袋:开奖时间相同且内容相同
|
||||
if abs(r_ft - future_ts) < 5.0 and r_content == content:
|
||||
already_reserved = True
|
||||
@@ -5417,7 +5417,9 @@ def basic_join_decision(
|
||||
future_ts=int(future_ts),
|
||||
content=content[:50] if content else "",
|
||||
existing_future_ts=int(r_ft),
|
||||
existing_content=r_content[:50] if r_content else "",
|
||||
existing_content=(
|
||||
r_content[:50] if r_content else ""
|
||||
),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
@@ -5499,7 +5501,9 @@ def basic_join_decision(
|
||||
if stage == "FUDai_DETAIL":
|
||||
# 尝试通过像素检测获取任务数量
|
||||
try:
|
||||
from douyin.detection import douyin_pixel
|
||||
from douyin.detection import (
|
||||
douyin_pixel,
|
||||
)
|
||||
|
||||
pic_path = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
@@ -5548,10 +5552,18 @@ def basic_join_decision(
|
||||
if isinstance(result, tuple):
|
||||
_, detect_info = result
|
||||
detected_task_count = (
|
||||
detect_info.get("task_count", 0)
|
||||
detect_info.get(
|
||||
"task_count", 0
|
||||
)
|
||||
)
|
||||
if detected_task_count in (1, 2, 3):
|
||||
task_count = detected_task_count
|
||||
if detected_task_count in (
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
):
|
||||
task_count = (
|
||||
detected_task_count
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
@@ -5649,7 +5661,8 @@ def basic_join_decision(
|
||||
in_lock_period = False
|
||||
try:
|
||||
focus_until = float(
|
||||
getattr(analyser, "reservation_focus_until_ts", 0.0) or 0.0
|
||||
getattr(analyser, "reservation_focus_until_ts", 0.0)
|
||||
or 0.0
|
||||
)
|
||||
now_ts = time.time()
|
||||
if focus_until > 0 and now_ts < focus_until:
|
||||
@@ -5683,11 +5696,15 @@ def basic_join_decision(
|
||||
# 兜底:直接调用底层 swipe(基于 1080x2400 基准坐标)
|
||||
try:
|
||||
rx = int(
|
||||
getattr(analyser, "resolution_ratio_x", 1080)
|
||||
getattr(
|
||||
analyser, "resolution_ratio_x", 1080
|
||||
)
|
||||
or 1080
|
||||
)
|
||||
ry = int(
|
||||
getattr(analyser, "resolution_ratio_y", 2400)
|
||||
getattr(
|
||||
analyser, "resolution_ratio_y", 2400
|
||||
)
|
||||
or 2400
|
||||
)
|
||||
except Exception:
|
||||
|
||||
@@ -5,6 +5,7 @@ import random
|
||||
import time
|
||||
from typing import Any
|
||||
import cv2 as _cv2
|
||||
|
||||
cv2: Any = _cv2
|
||||
# pylint: disable=E1101
|
||||
import numpy as np
|
||||
|
||||
Reference in new issue
Block a user