Files
douyin_guaji-main/douyin_swipe_ops.py
T
Your Name 47e6b016c5 refactor: Remove deprecated files and enhance configuration settings
- Deleted outdated markdown files and scripts related to previous implementations.
- Updated `config.json` to adjust thresholds and settings for 福袋 detection and reservation handling.
- Improved logging and error handling across various modules for better monitoring and user experience.
- Introduced a new screenshot management module to facilitate real-time operation and success tracking.
- Enhanced GUI elements to support new configuration options and improve usability.
2025-12-20 20:11:28 +08:00

105 lines
3.1 KiB
Python

from __future__ import annotations
from typing import Any
def swipe_up_switch_live(analyser: Any) -> None:
"""上滑切换到下一个直播间(基础版封装)。
采用 1080x2400 基准坐标,在屏幕中下部向上滑一段距离。
"""
try:
rx = int(getattr(analyser, "resolution_ratio_x", 1080) or 1080)
except Exception:
rx = 1080
try:
ry = int(getattr(analyser, "resolution_ratio_y", 2400) or 2400)
except Exception:
ry = 2400
device_id = getattr(analyser, "device_id", "")
# 基准坐标(1080x2400):从中下部往上滑
start_x_base = 540
start_y_base = 1700
end_x_base = 540
end_y_base = 700
start_x = start_x_base * rx // 1080
end_x = end_x_base * rx // 1080
start_y = start_y_base * ry // 2400
end_y = end_y_base * ry // 2400
try:
analyser._log_kv(
"滑动",
"swipe_up_switch_live:上滑切换直播间",
start_x=start_x_base,
start_y=start_y_base,
end_x=end_x_base,
end_y=end_y_base,
)
except Exception:
pass
# 优先调用底层 swipe,失败则静默忽略(不影响主流程)
try:
analyser.operation.swipe(device_id, start_x, start_y, end_x, end_y, 300)
except Exception:
try:
# 如果 analyser 自身提供 swipe 封装,则退回到该封装
analyser.swipe(start_x_base, start_y_base, end_x_base, end_y_base, 300)
except Exception:
pass
def swipe_down_back_live(analyser: Any) -> None:
"""上划回退到上一个直播间(基础版封装)。
在直播间内,向上滑动可以回退到上一个直播间。
采用 1080x2400 基准坐标,在屏幕中下部向上滑一段距离。
"""
try:
rx = int(getattr(analyser, "resolution_ratio_x", 1080) or 1080)
except Exception:
rx = 1080
try:
ry = int(getattr(analyser, "resolution_ratio_y", 2400) or 2400)
except Exception:
ry = 2400
device_id = getattr(analyser, "device_id", "")
# 基准坐标(1080x2400):从中下部往上滑(与上滑切换相同方向)
start_x_base = 540
start_y_base = 1700
end_x_base = 540
end_y_base = 700
start_x = start_x_base * rx // 1080
end_x = end_x_base * rx // 1080
start_y = start_y_base * ry // 2400
end_y = end_y_base * ry // 2400
try:
analyser._log_kv(
"滑动",
"swipe_down_back_live:上划回退到上一个直播间",
start_x=start_x_base,
start_y=start_y_base,
end_x=end_x_base,
end_y=end_y_base,
)
except Exception:
pass
# 优先调用底层 swipe,失败则静默忽略(不影响主流程)
try:
analyser.operation.swipe(device_id, start_x, start_y, end_x, end_y, 300)
except Exception:
try:
# 如果 analyser 自身提供 swipe 封装,则退回到该封装
analyser.swipe(start_x_base, start_y_base, end_x_base, end_y_base, 300)
except Exception:
pass