feat: 增加Docker容器环境

This commit is contained in:
听风
2025-11-06 14:50:19 +08:00
parent 7de1a30b92
commit de2389c9b1
14 changed files with 135 additions and 41 deletions
+5 -3
View File
@@ -9,11 +9,12 @@ from uploader.tk_uploader.tk_config import Tk_Locator
from utils.base_social_media import set_init_script
from utils.files_times import get_absolute_path
from utils.log import tiktok_logger
from conf import LOCAL_CHROME_HEADLESS
async def cookie_auth(account_file):
async with async_playwright() as playwright:
browser = await playwright.firefox.launch(headless=True)
browser = await playwright.firefox.launch(headless=LOCAL_CHROME_HEADLESS)
context = await browser.new_context(storage_state=account_file)
context = await set_init_script(context)
# 创建一个新的页面
@@ -53,7 +54,7 @@ async def get_tiktok_cookie(account_file):
'args': [
'--lang en-GB',
],
'headless': False, # Set headless option here
'headless': LOCAL_CHROME_HEADLESS, # Set headless option here
}
# Make sure to run headed.
browser = await playwright.firefox.launch(**options)
@@ -75,6 +76,7 @@ class TiktokVideo(object):
self.tags = tags
self.publish_date = publish_date
self.account_file = account_file
self.headless = LOCAL_CHROME_HEADLESS
self.locator_base = None
@@ -140,7 +142,7 @@ class TiktokVideo(object):
await file_chooser.set_files(self.file_path)
async def upload(self, playwright: Playwright) -> None:
browser = await playwright.firefox.launch(headless=False)
browser = await playwright.firefox.launch(headless=self.headless)
context = await browser.new_context(storage_state=f"{self.account_file}")
context = await set_init_script(context)
page = await context.new_page()