bin/run_cli.py 的 _BASE_DIR+sys.path.insert 原在 logging import 之后, 导致 No module named 'douyin' 警告。tools/ 下 5 个脚本完全缺失 sys.path 设置,auto_connect_wifi_adb.py 层级算错只跳到 tools/ 而非项目根。
56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
import os
|
|
import sys
|
|
|
|
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
if _PROJECT_ROOT not in sys.path:
|
|
sys.path.insert(0, _PROJECT_ROOT)
|
|
|
|
from douyin.core.douyin_fudai import fudai_analyse
|
|
from douyin.handlers import douyin_swipe_ops
|
|
|
|
|
|
class DummyOp:
|
|
def swipe(self, device_id, sx, sy, ex, ey, duration_ms):
|
|
# minimal output
|
|
print(
|
|
f"swipe: device={device_id} from=({sx},{sy}) to=({ex},{ey}) dur={duration_ms}"
|
|
)
|
|
|
|
def click_back(self, device_id=None):
|
|
print(f"click_back called, device={device_id}")
|
|
|
|
|
|
def main():
|
|
a = fudai_analyse()
|
|
a.operation = DummyOp()
|
|
a.device_id = "DUMMY"
|
|
# use config default of 10 to simulate ten swipes
|
|
a.fudai_exit_after_misses = int(getattr(a, "fudai_exit_after_misses", 10) or 10)
|
|
print("fudai_exit_after_misses =", a.fudai_exit_after_misses)
|
|
# ensure counter starts at 0
|
|
a._consecutive_no_fudai_count = 0
|
|
|
|
for i in range(1, 11):
|
|
print(f"\n-- swipe #{i} --")
|
|
douyin_swipe_ops.swipe_up_switch_live(a)
|
|
# simulate not finding fudai -> increment counter
|
|
a._consecutive_no_fudai_count = (
|
|
int(getattr(a, "_consecutive_no_fudai_count", 0)) + 1
|
|
)
|
|
print("consecutive_no_fudai_count =", a._consecutive_no_fudai_count)
|
|
if a._consecutive_no_fudai_count >= a.fudai_exit_after_misses:
|
|
print("threshold reached, invoking back")
|
|
try:
|
|
a.operation.click_back(a.device_id)
|
|
except Exception:
|
|
print("click_back failed")
|
|
# reset counter as real logic would
|
|
a._consecutive_no_fudai_count = 0
|
|
break
|
|
else:
|
|
print("\nNo back triggered after 10 swipes")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|