autoUpload/examples/get_douyin_cookie.py

21 lines
736 B
Python
Raw Normal View History

2025-09-08 09:32:45 +08:00
# 在文件开头添加以下代码(在原导入语句之前)
import sys
import os
# 获取当前脚本所在目录
current_dir = os.path.dirname(os.path.abspath(__file__))
# 项目根目录是当前目录的上一级因为examples目录和conf.py同级
project_root = os.path.dirname(current_dir)
# 将项目根目录添加到系统路径
sys.path.append(project_root)
import asyncio
from pathlib import Path
from conf import BASE_DIR
from uploader.douyin_uploader.main import douyin_setup
if __name__ == '__main__':
account_file = Path(BASE_DIR / "cookies" / "douyin_uploader" / "account.json")
account_file.parent.mkdir(exist_ok=True)
cookie_setup = asyncio.run(douyin_setup(str(account_file), handle=True))