feat: 增加Docker容器环境
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -6,7 +6,7 @@ from playwright.async_api import Playwright, async_playwright
|
||||
import os
|
||||
import asyncio
|
||||
|
||||
from conf import LOCAL_CHROME_PATH
|
||||
from conf import LOCAL_CHROME_PATH, LOCAL_CHROME_HEADLESS
|
||||
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
|
||||
@@ -15,7 +15,7 @@ from utils.log import tiktok_logger
|
||||
|
||||
async def cookie_auth(account_file):
|
||||
async with async_playwright() as playwright:
|
||||
browser = await playwright.chromium.launch(headless=True)
|
||||
browser = await playwright.chromium.launch(headless=LOCAL_CHROME_HEADLESS)
|
||||
context = await browser.new_context(storage_state=account_file)
|
||||
context = await set_init_script(context)
|
||||
# 创建一个新的页面
|
||||
@@ -55,7 +55,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.chromium.launch(**options)
|
||||
@@ -79,6 +79,7 @@ class TiktokVideo(object):
|
||||
self.thumbnail_path = thumbnail_path
|
||||
self.account_file = account_file
|
||||
self.local_executable_path = LOCAL_CHROME_PATH
|
||||
self.headless = LOCAL_CHROME_HEADLESS
|
||||
self.locator_base = None
|
||||
|
||||
async def set_schedule_time(self, page, publish_date):
|
||||
@@ -146,7 +147,7 @@ class TiktokVideo(object):
|
||||
await file_chooser.set_files(self.file_path)
|
||||
|
||||
async def upload(self, playwright: Playwright) -> None:
|
||||
browser = await playwright.chromium.launch(headless=False, executable_path=self.local_executable_path)
|
||||
browser = await playwright.chromium.launch(headless=self.headless, executable_path=self.local_executable_path)
|
||||
context = await browser.new_context(storage_state=f"{self.account_file}")
|
||||
# context = await set_init_script(context)
|
||||
page = await context.new_page()
|
||||
|
||||
Reference in New Issue
Block a user