| 1 | from __future__ import annotations |
| 2 | |
| 3 | import shlex |
| 4 | import subprocess |
| 5 | |
| 6 | |
| 7 | def run_command(command: list[str]) -> None: |
| 8 | print("Running:", " ".join(shlex.quote(part) for part in command)) |
| 9 | subprocess.run(command, check=True) |
| 10 | |
| 11 | |
| 12 | def main() -> None: |
| 13 | account = "account_a" |
| 14 | # account_name is user-defined. One account_name maps to one account file. |
| 15 | # You can prepare multiple account names and run them in parallel. |
| 16 | |
| 17 | commands = [ |
| 18 | ["sau", "douyin", "login", "--account", account, "--headless"], |
| 19 | ["sau", "douyin", "check", "--account", account], |
| 20 | [ |
| 21 | "sau", |
| 22 | "douyin", |
| 23 | "upload-video", |
| 24 | "--account", |
| 25 | account, |
| 26 | "--file", |
| 27 | "videos/demo.mp4", |
| 28 | "--title", |
| 29 | "Douyin video from Python", |
| 30 | "--desc", |
| 31 | "Douyin video description from Python", |
| 32 | "--tags", |
| 33 | "cli,video", |
| 34 | "--thumbnail", |
| 35 | "videos/demo.png", |
| 36 | "--headless", |
| 37 | ], |
| 38 | [ |
| 39 | "sau", |
| 40 | "douyin", |
| 41 | "upload-note", |
| 42 | "--account", |
| 43 | account, |
| 44 | "--images", |
| 45 | "videos/1.png", |
| 46 | "videos/2.png", |
| 47 | "--title", |
| 48 | "Douyin note title from Python", |
| 49 | "--note", |
| 50 | "Douyin note from Python", |
| 51 | "--tags", |
| 52 | "cli,note", |
| 53 | "--headless", |
| 54 | ], |
| 55 | ] |
| 56 | |
| 57 | for command in commands: |
| 58 | run_command(command) |
| 59 | |
| 60 | |
| 61 | if __name__ == "__main__": |
| 62 | main() |
| 63 |