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
+6
View File
@@ -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
+4
View File
@@ -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,6 +83,9 @@ class DouYinVideo(object):
async def upload(self, playwright: Playwright) -> None:
# 使用 Chromium 浏览器启动一个浏览器实例
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}")