feat: 优化预约状态加载逻辑,支持从 JSON 文件回退读取状态
This commit is contained in:
1 parent
f7da7b78aa
commit
161e2e9491
2 files changed
+53
-17
No files matched your search
@@ -1346,7 +1346,24 @@ class fudai_analyse:
|
||||
try:
|
||||
from douyin.reservation import douyin_reservation as dr
|
||||
|
||||
loaded = dr.load_reservations_state(state_path)
|
||||
if hasattr(dr, "load_reservations_state"):
|
||||
loaded = dr.load_reservations_state(state_path)
|
||||
else:
|
||||
# 回退:尝试直接读取状态文件的 JSON 格式
|
||||
try:
|
||||
import json
|
||||
|
||||
if os.path.exists(state_path):
|
||||
with open(state_path, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
if isinstance(data, dict) and "reservations" in data:
|
||||
loaded = data.get("reservations", [])
|
||||
elif isinstance(data, list):
|
||||
loaded = data
|
||||
else:
|
||||
loaded = []
|
||||
except Exception:
|
||||
loaded = []
|
||||
except Exception:
|
||||
loaded = []
|
||||
|
||||
@@ -2471,8 +2488,11 @@ class fudai_analyse:
|
||||
and isinstance(detail, tuple)
|
||||
and len(detail) >= 6
|
||||
):
|
||||
# 使用索引读取以避免静态分析对解包的误报
|
||||
countdown_tuple = detail[5]
|
||||
# 使用索引读取并使用 try/except 以避免静态分析对解包/下标的误报
|
||||
try:
|
||||
countdown_tuple = detail[5]
|
||||
except Exception:
|
||||
countdown_tuple = ()
|
||||
if (
|
||||
isinstance(countdown_tuple, (tuple, list))
|
||||
and len(countdown_tuple) >= 2
|
||||
@@ -2773,7 +2793,9 @@ class fudai_analyse:
|
||||
)
|
||||
or "adb"
|
||||
)
|
||||
if not adb_cmd.startswith('"') and not adb_cmd.endswith('"'):
|
||||
if not adb_cmd.startswith(
|
||||
'"'
|
||||
) and not adb_cmd.endswith('"'):
|
||||
adb_cmd = f'"{adb_cmd}"'
|
||||
cmd = f"{adb_cmd} -s {self.device_id} shell input swipe {start_x} {start_y} {end_x} {end_y} 300"
|
||||
subprocess.run(
|
||||
@@ -2949,7 +2971,9 @@ class fudai_analyse:
|
||||
)
|
||||
or "adb"
|
||||
)
|
||||
if not adb_cmd.startswith('"') and not adb_cmd.endswith('"'):
|
||||
if not adb_cmd.startswith(
|
||||
'"'
|
||||
) and not adb_cmd.endswith('"'):
|
||||
adb_cmd = f'"{adb_cmd}"'
|
||||
cmd = f"{adb_cmd} -s {self.device_id} shell input swipe {start_x} {start_y} {end_x} {end_y} 300"
|
||||
subprocess.run(
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
{
|
||||
"updated_ts": 1767491436.7967348,
|
||||
"reason": "process_reservation",
|
||||
"updated_ts": 1767491537.0721958,
|
||||
"reason": "record_reservation",
|
||||
"room_pos": 3,
|
||||
"current_room_title": "火火来",
|
||||
"current_room_title_raw": "",
|
||||
"current_room_title": "带娃的小",
|
||||
"current_room_title_raw": "带娃的小.",
|
||||
"reservations": [
|
||||
{
|
||||
"prize_value_yuan": 5999.0,
|
||||
"prize_value_yuan": 699.0,
|
||||
"content": "",
|
||||
"future_ts": 1767491526.677024,
|
||||
"future_str": "2026-01-04 09:52:06",
|
||||
"future_ts": 1767491839.675532,
|
||||
"future_str": "2026-01-04 09:57:19",
|
||||
"pos_seen": 3,
|
||||
"room_title": "刘媛媛媛",
|
||||
"room_title_raw": "刘媛媛.媛",
|
||||
"created_ts": 1767491172.3842542
|
||||
"room_title": "带娃的小",
|
||||
"room_title_raw": "带娃的小.",
|
||||
"created_ts": 1767491462.9488251,
|
||||
"task_count": 2,
|
||||
"time_text": "06:22",
|
||||
"participants": 0,
|
||||
"copies": 0
|
||||
},
|
||||
{
|
||||
"prize_value_yuan": 1999.0,
|
||||
@@ -23,7 +27,11 @@
|
||||
"pos_seen": 0,
|
||||
"room_title": "作川帮数",
|
||||
"room_title_raw": "作川帮数。。",
|
||||
"created_ts": 1767491317.7698174
|
||||
"created_ts": 1767491317.7698174,
|
||||
"task_count": 2,
|
||||
"time_text": "14:41",
|
||||
"participants": 0,
|
||||
"copies": 0
|
||||
},
|
||||
{
|
||||
"prize_value_yuan": 1999.0,
|
||||
@@ -33,7 +41,11 @@
|
||||
"pos_seen": 0,
|
||||
"room_title": "作帮粼",
|
||||
"room_title_raw": "作!帮粼。。",
|
||||
"created_ts": 1767491385.7829947
|
||||
"created_ts": 1767491385.7829947,
|
||||
"task_count": 2,
|
||||
"time_text": "13:33",
|
||||
"participants": 0,
|
||||
"copies": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user