Files
auto_control/main.py
T

44 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""抖音养号命令行入口。
直接运行:python main.py
- 单设备跑一次养号,不走 web/调度
- 任务参数默认值在 tasks/douyin_nurture.py 顶部,可通过环境变量 WATCH_COUNT 覆盖视频数
web 管理后台请运行:python web_server.py
清理 STF 残留占用:python scripts/cleanup.py
目录结构:
config.py — 项目根配置(STF 地址/token、adb 路径、web 端口、数据目录)
bin/adb/ — adb.exe 及依赖 dll
core/ — 核心程序(STF 客户端、adb 工具、BaseWorker 基类、任务管理器)
tasks/ — 任务定义(每个任务一个 .py,自带参数默认值,继承 BaseTask + @register_task)
web/ — 前端页面(index.html)
data/ — 持久化数据(分组、任务计划)
scripts/ — 实用脚本
"""
import os
from core.stf_client import STFClient
from tasks import get_task_class
def run_once(serial=None, **overrides):
"""单设备跑一次养号(命令行入口,不启动 web)。
走任务框架:取 douyin_nurture 任务类 → create_worker → 直接 run(当前线程)。
overrides 可传任务参数覆盖默认值,如 run_once(watch_count=20, like_enabled=False)。
"""
stf = STFClient()
task_cls = get_task_class("douyin_nurture")
task = task_cls()
params = dict(overrides)
# 命令行友好:环境变量 WATCH_COUNT 覆盖视频数
if "WATCH_COUNT" in os.environ and "watch_count" not in params:
params["watch_count"] = int(os.environ["WATCH_COUNT"])
worker = task.create_worker(stf, serial, params)
worker.run() # 直接在当前线程跑,不起子线程
if __name__ == "__main__":
run_once()