From b10c66b6220cd50d820322eae440cc37b77bd3cc Mon Sep 17 00:00:00 2001 From: "pookz@stme" Date: Fri, 15 Dec 2023 13:17:56 +0800 Subject: [PATCH] fix douyin video pic bug --- README.MD | 8 +++++++- douyin_uploader/main.py | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.MD b/README.MD index db559a0..3b9147a 100644 --- a/README.MD +++ b/README.MD @@ -58,7 +58,7 @@ meta_file 内容: > 抖音前端实现,诸多css class id 均为随机数,故项目中locator多采用相对定位,而非固定定位 1. 准备视频目录结构 2. cookie获取:get_douyin_cookie.py 扫码登录 -3. 上传视频:upload_video_to_douyin.py +3. 上传视频:upload_video_to_douyin.py @@ -74,6 +74,12 @@ generate_schedule_time_next_day 默认从第二天开始(此举为避免选择 - start_days 从第N天开始 ``` +> 2023年12月15日补充:使用chromium可能会出现无法识别视频封面图片的情况 +> 解决方案: +> 1. 下载chrome +> 2. 找到chrome的安装目录 +> 3. 将目录配置到DouYinVideo类中 self.local_executable_path = "xxx/xxx/chrome.exe" + 参考项目: - https://github.com/wanghaisheng/tiktoka-studio-uploader diff --git a/douyin_uploader/main.py b/douyin_uploader/main.py index ef913d3..f907df2 100644 --- a/douyin_uploader/main.py +++ b/douyin_uploader/main.py @@ -59,6 +59,7 @@ class DouYinVideo(object): self.publish_date = publish_date self.account_file = account_file self.date_format = '%Y年%m月%d日 %H:%M' + self.local_executable_path = "" # change me async def set_schedule_time_douyin(self, page, publish_date): # 选择包含特定文本内容的 label 元素 @@ -82,7 +83,10 @@ class DouYinVideo(object): async def upload(self, playwright: Playwright) -> None: # 使用 Chromium 浏览器启动一个浏览器实例 - browser = await playwright.chromium.launch(headless=False) + if self.local_executable_path: + browser = await playwright.chromium.launch(headless=False, executable_path=self.local_executable_path) + else: + browser = await playwright.chromium.launch(headless=False) # 创建一个浏览器上下文,使用指定的 cookie 文件 context = await browser.new_context(storage_state=f"{self.account_file}")