Files
EveryPublish/sau_backend/examples/upload_video_to_tencent.py
T

29 lines
1.3 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.
import asyncio
from pathlib import Path
from sau_backend.conf import BASE_DIR
from sau_backend.uploader.tencent_uploader.main import weixin_setup, TencentVideo
from sau_backend.utils.constant import TencentZoneTypes
from sau_backend.utils.files_times import generate_schedule_time_next_day, get_title_and_hashtags
if __name__ == '__main__':
filepath = Path(BASE_DIR) / "videos"
account_file = Path(BASE_DIR / "cookies" / "tencent_uploader" / "account.json")
# 获取视频目录
folder_path = Path(filepath)
# 获取文件夹中的所有文件
files = list(folder_path.glob("*.mp4"))
file_num = len(files)
publish_datetimes = generate_schedule_time_next_day(file_num, 1, daily_times=[16])
cookie_setup = asyncio.run(weixin_setup(account_file, handle=True))
category = TencentZoneTypes.LIFESTYLE.value # 标记原创需要否则不需要传
for index, file in enumerate(files):
title, tags = get_title_and_hashtags(str(file))
# 打印视频文件名、标题和 hashtag
print(f"视频文件名:{file}")
print(f"标题:{title}")
print(f"Hashtag:{tags}")
app = TencentVideo(title, file, tags, publish_datetimes[index], account_file, category)
asyncio.run(app.main(), debug=False)