Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
459 changes: 459 additions & 0 deletions api.py

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion cli_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
from pathlib import Path

from conf import BASE_DIR
from uploader.bilibili_uploader.main import bilibili_setup, BiliBiliUploader
from uploader.douyin_uploader.main import douyin_setup, DouYinVideo
from uploader.ks_uploader.main import ks_setup, KSVideo
from uploader.tencent_uploader.main import weixin_setup, TencentVideo
from uploader.tk_uploader.main_chrome import tiktok_setup, TiktokVideo
from utils.base_social_media import get_supported_social_media, get_cli_action, SOCIAL_MEDIA_DOUYIN, \
SOCIAL_MEDIA_TENCENT, SOCIAL_MEDIA_TIKTOK, SOCIAL_MEDIA_KUAISHOU
SOCIAL_MEDIA_TENCENT, SOCIAL_MEDIA_TIKTOK, SOCIAL_MEDIA_KUAISHOU, SOCIAL_MEDIA_BILIBILI
from utils.constant import TencentZoneTypes
from utils.files_times import get_title_and_hashtags

Expand Down Expand Up @@ -66,6 +67,8 @@ async def main():
await weixin_setup(str(account_file), handle=True)
elif args.platform == SOCIAL_MEDIA_KUAISHOU:
await ks_setup(str(account_file), handle=True)
elif args.platform == SOCIAL_MEDIA_BILIBILI:
await bilibili_setup(str(account_file), handle=True)
elif args.action == 'upload':
title, tags = get_title_and_hashtags(args.video_file)
video_file = args.video_file
Expand All @@ -90,6 +93,10 @@ async def main():
elif args.platform == SOCIAL_MEDIA_KUAISHOU:
await ks_setup(account_file, handle=True)
app = KSVideo(title, video_file, tags, publish_date, account_file)
elif args.platform == SOCIAL_MEDIA_BILIBILI:
await bilibili_setup(account_file, handle=True)
app = BiliBiliUploader(title, video_file, tags, publish_date, account_file)

else:
print("Wrong platform, please check your input")
exit()
Expand Down
527 changes: 527 additions & 0 deletions gui.py

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ cf_clearance
biliup
xhs
qrcode
loguru
loguru
pyside6
fastapi
uvicorn
pydantic
python-multipart
419 changes: 354 additions & 65 deletions uploader/bilibili_uploader/main.py

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions uploader/douyin_uploader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import asyncio

from conf import LOCAL_CHROME_PATH
from utils import file_utils
from utils.base_social_media import set_init_script
from utils.log import douyin_logger

Expand Down Expand Up @@ -95,6 +96,11 @@ async def handle_upload_error(self, page):
await page.locator('div.progress-div [class^="upload-btn-input"]').set_input_files(self.file_path)

async def upload(self, playwright: Playwright) -> None:
# 在这之前需要校验一下视频文件大小,抖音的web限制上传文件为1G 因此,请注意不要上传超过1G大小的文件
if file_utils.check_video_size(self.file_path, 1024):
# 如果超过1G,直接返回报错
douyin_logger.error('视频文件超过1G,请重新上传')
raise Exception('视频文件超过1G,超过抖音限制了,无法上传。')
# 使用 Chromium 浏览器启动一个浏览器实例
if self.local_executable_path:
browser = await playwright.chromium.launch(headless=False, executable_path=self.local_executable_path)
Expand Down
11 changes: 11 additions & 0 deletions utils/file_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os



# 校验视频文件的大小,入参需要视频文件绝对路径,以及需要校验的大小,单位为MB
def check_video_size(video_path, size):
if not os.path.exists(video_path):
return False
if os.path.getsize(video_path) < size * 1024 * 1024:
return False
return True