fix douyin video pic bug

This commit is contained in:
pookz@stme
2023-12-15 13:17:56 +08:00
parent 44da1829d8
commit b10c66b622
2 changed files with 12 additions and 2 deletions
+7 -1
View File
@@ -58,7 +58,7 @@ meta_file 内容:
> 抖音前端实现,诸多css class id 均为随机数,故项目中locator多采用相对定位,而非固定定位 > 抖音前端实现,诸多css class id 均为随机数,故项目中locator多采用相对定位,而非固定定位
1. 准备视频目录结构 1. 准备视频目录结构
2. cookie获取:get_douyin_cookie.py 扫码登录 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天开始 - 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 - https://github.com/wanghaisheng/tiktoka-studio-uploader
+5 -1
View File
@@ -59,6 +59,7 @@ class DouYinVideo(object):
self.publish_date = publish_date self.publish_date = publish_date
self.account_file = account_file self.account_file = account_file
self.date_format = '%Y年%m月%d日 %H:%M' self.date_format = '%Y年%m月%d日 %H:%M'
self.local_executable_path = "" # change me
async def set_schedule_time_douyin(self, page, publish_date): async def set_schedule_time_douyin(self, page, publish_date):
# 选择包含特定文本内容的 label 元素 # 选择包含特定文本内容的 label 元素
@@ -82,7 +83,10 @@ class DouYinVideo(object):
async def upload(self, playwright: Playwright) -> None: async def upload(self, playwright: Playwright) -> None:
# 使用 Chromium 浏览器启动一个浏览器实例 # 使用 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 文件 # 创建一个浏览器上下文,使用指定的 cookie 文件
context = await browser.new_context(storage_state=f"{self.account_file}") context = await browser.new_context(storage_state=f"{self.account_file}")