| 1 | import asyncio |
| 2 | from pathlib import Path |
| 3 | |
| 4 | from conf import BASE_DIR |
| 5 | from uploader.douyin_uploader.main import DouYinVideo |
| 6 | from uploader.ks_uploader.main import KSVideo |
| 7 | from uploader.tencent_uploader.main import TencentVideo |
| 8 | from uploader.xiaohongshu_uploader.main import XiaoHongShuVideo |
| 9 | from utils.constant import TencentZoneTypes |
| 10 | from utils.files_times import generate_schedule_time_next_day |
| 11 | |
| 12 | |
| 13 | def post_video_tencent(title,files,tags,account_file,category=TencentZoneTypes.LIFESTYLE.value,enableTimer=False,videos_per_day = 1, daily_times=None,start_days = 0, is_draft=False): |
| 14 | # 生成文件的完整路径 |
| 15 | account_file = [Path(BASE_DIR / "cookiesFile" / file) for file in account_file] |
| 16 | files = [Path(BASE_DIR / "videoFile" / file) for file in files] |
| 17 | if enableTimer: |
| 18 | publish_datetimes = generate_schedule_time_next_day(len(files), videos_per_day, daily_times,start_days) |
| 19 | else: |
| 20 | publish_datetimes = [0 for i in range(len(files))] |
| 21 | for index, file in enumerate(files): |
| 22 | for cookie in account_file: |
| 23 | print(f"文件路径{str(file)}") |
| 24 | # 打印视频文件名、标题和 hashtag |
| 25 | print(f"视频文件名:{file}") |
| 26 | print(f"标题:{title}") |
| 27 | print(f"Hashtag:{tags}") |
| 28 | app = TencentVideo(title, str(file), tags, publish_datetimes[index], cookie, category, is_draft) |
| 29 | asyncio.run(app.main(), debug=False) |
| 30 | |
| 31 | |
| 32 | def post_video_DouYin(title,files,tags,account_file,category=TencentZoneTypes.LIFESTYLE.value,enableTimer=False,videos_per_day = 1, daily_times=None,start_days = 0, |
| 33 | thumbnail_path = '', |
| 34 | productLink = '', productTitle = ''): |
| 35 | # 生成文件的完整路径 |
| 36 | account_file = [Path(BASE_DIR / "cookiesFile" / file) for file in account_file] |
| 37 | files = [Path(BASE_DIR / "videoFile" / file) for file in files] |
| 38 | if enableTimer: |
| 39 | publish_datetimes = generate_schedule_time_next_day(len(files), videos_per_day, daily_times,start_days) |
| 40 | else: |
| 41 | publish_datetimes = [0 for i in range(len(files))] |
| 42 | for index, file in enumerate(files): |
| 43 | for cookie in account_file: |
| 44 | print(f"文件路径{str(file)}") |
| 45 | # 打印视频文件名、标题和 hashtag |
| 46 | print(f"视频文件名:{file}") |
| 47 | print(f"标题:{title}") |
| 48 | print(f"Hashtag:{tags}") |
| 49 | app = DouYinVideo(title, str(file), tags, publish_datetimes[index], cookie, thumbnail_path, productLink, productTitle) |
| 50 | asyncio.run(app.douyin_upload_video(), debug=False) |
| 51 | |
| 52 | |
| 53 | def post_video_ks(title,files,tags,account_file,category=TencentZoneTypes.LIFESTYLE.value,enableTimer=False,videos_per_day = 1, daily_times=None,start_days = 0): |
| 54 | # 生成文件的完整路径 |
| 55 | account_file = [Path(BASE_DIR / "cookiesFile" / file) for file in account_file] |
| 56 | files = [Path(BASE_DIR / "videoFile" / file) for file in files] |
| 57 | if enableTimer: |
| 58 | publish_datetimes = generate_schedule_time_next_day(len(files), videos_per_day, daily_times,start_days) |
| 59 | else: |
| 60 | publish_datetimes = [0 for i in range(len(files))] |
| 61 | for index, file in enumerate(files): |
| 62 | for cookie in account_file: |
| 63 | print(f"文件路径{str(file)}") |
| 64 | # 打印视频文件名、标题和 hashtag |
| 65 | print(f"视频文件名:{file}") |
| 66 | print(f"标题:{title}") |
| 67 | print(f"Hashtag:{tags}") |
| 68 | app = KSVideo(title, str(file), tags, publish_datetimes[index], cookie) |
| 69 | asyncio.run(app.main(), debug=False) |
| 70 | |
| 71 | def post_video_xhs(title,files,tags,account_file,category=TencentZoneTypes.LIFESTYLE.value,enableTimer=False,videos_per_day = 1, daily_times=None,start_days = 0): |
| 72 | # 生成文件的完整路径 |
| 73 | account_file = [Path(BASE_DIR / "cookiesFile" / file) for file in account_file] |
| 74 | files = [Path(BASE_DIR / "videoFile" / file) for file in files] |
| 75 | file_num = len(files) |
| 76 | if enableTimer: |
| 77 | publish_datetimes = generate_schedule_time_next_day(file_num, videos_per_day, daily_times,start_days) |
| 78 | else: |
| 79 | publish_datetimes = 0 |
| 80 | for index, file in enumerate(files): |
| 81 | for cookie in account_file: |
| 82 | # 打印视频文件名、标题和 hashtag |
| 83 | print(f"视频文件名:{file}") |
| 84 | print(f"标题:{title}") |
| 85 | print(f"Hashtag:{tags}") |
| 86 | app = XiaoHongShuVideo(title, file, tags, publish_datetimes, cookie) |
| 87 | asyncio.run(app.main(), debug=False) |
| 88 | |
| 89 | |
| 90 | |
| 91 | # post_video("333",["demo.mp4"],"d","d") |
| 92 | # post_video_DouYin("333",["demo.mp4"],"d","d") |