| 1 | import asyncio |
| 2 | from pathlib import Path |
| 3 | |
| 4 | from conf import BASE_DIR |
| 5 | # from tk_uploader.main import tiktok_setup, TiktokVideo |
| 6 | from uploader.tk_uploader.main_chrome import tiktok_setup, TiktokVideo |
| 7 | from utils.files_times import generate_schedule_time_next_day, get_title_and_hashtags |
| 8 | |
| 9 | |
| 10 | if __name__ == '__main__': |
| 11 | filepath = Path(BASE_DIR) / "videos" |
| 12 | account_file = Path(BASE_DIR / "cookies" / "tk_uploader" / "account.json") |
| 13 | folder_path = Path(filepath) |
| 14 | # get video files from folder |
| 15 | files = list(folder_path.glob("*.mp4")) |
| 16 | file_num = len(files) |
| 17 | publish_datetimes = generate_schedule_time_next_day(file_num, 1, daily_times=[16]) |
| 18 | cookie_setup = asyncio.run(tiktok_setup(account_file, handle=True)) |
| 19 | for index, file in enumerate(files): |
| 20 | title, tags = get_title_and_hashtags(str(file)) |
| 21 | thumbnail_path = file.with_suffix('.png') |
| 22 | print(f"video_file_name:{file}") |
| 23 | print(f"video_title:{title}") |
| 24 | print(f"video_hashtag:{tags}") |
| 25 | if thumbnail_path.exists(): |
| 26 | print(f"thumbnail_file_name:{thumbnail_path}") |
| 27 | app = TiktokVideo(title, file, tags, publish_datetimes[index], account_file, thumbnail_path) |
| 28 | else: |
| 29 | app = TiktokVideo(title, file, tags, publish_datetimes[index], account_file) |
| 30 | asyncio.run(app.main(), debug=False) |
| 31 |