feat: 抖音登录态检测逻辑更新支持
This commit is contained in:
parent
3c4695eed7
commit
764bafc626
|
@ -95,7 +95,7 @@
|
|||
> 7天有效期,自动更新, 如果人满了可以加作者wx拉进群: yzglan,备注来自github.
|
||||
|
||||
<div style="max-width: 200px">
|
||||
<p><img alt="8群二维码" src="static/images/8群二维码.JPG" style="width: 200px;height: 100%" ></p>
|
||||
<p><img alt="9群二维码" src="static/images/9群二维码.PNG" style="width: 200px;height: 100%" ></p>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -115,6 +115,8 @@
|
|||
|
||||
➡️➡️➡️ [常见问题](docs/常见问题.md)
|
||||
|
||||
抖音使用Playwright登录现在会出现滑块验证 + 短信验证,手动过一下
|
||||
|
||||
|
||||
## 项目代码结构
|
||||
➡️➡️➡️ [项目代码结构说明](docs/项目代码结构.md)
|
||||
|
|
|
@ -56,13 +56,15 @@ class AbstractStore(ABC):
|
|||
async def store_creator(self, creator: Dict):
|
||||
pass
|
||||
|
||||
|
||||
class AbstractStoreImage(ABC):
|
||||
#TODO: support all platform
|
||||
# TODO: support all platform
|
||||
# only weibo is supported
|
||||
# @abstractmethod
|
||||
async def store_image(self, image_content_item: Dict):
|
||||
pass
|
||||
|
||||
|
||||
class AbstractApiClient(ABC):
|
||||
@abstractmethod
|
||||
async def request(self, method, url, **kwargs):
|
||||
|
@ -71,7 +73,3 @@ class AbstractApiClient(ABC):
|
|||
@abstractmethod
|
||||
async def update_cookies(self, browser_context: BrowserContext):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def pong(self):
|
||||
pass
|
||||
|
|
|
@ -19,7 +19,7 @@ IP_PROXY_PROVIDER_NAME = "kuaidaili"
|
|||
# 设置False会打开一个浏览器
|
||||
# 小红书如果一直扫码登录不通过,打开浏览器手动过一下滑动验证码
|
||||
# 抖音如果一直提示失败,打开浏览器看下是否扫码登录之后出现了手机号验证,如果出现了手动过一下再试。
|
||||
HEADLESS = True
|
||||
HEADLESS = False
|
||||
|
||||
# 是否保存登录状态
|
||||
SAVE_LOGIN_STATE = True
|
||||
|
|
|
@ -86,10 +86,12 @@ class DOUYINClient(AbstractApiClient):
|
|||
headers = headers or self.headers
|
||||
return await self.request(method="POST", url=f"{self._host}{uri}", data=data, headers=headers)
|
||||
|
||||
@staticmethod
|
||||
async def pong(browser_context: BrowserContext) -> bool:
|
||||
async def pong(self, browser_context: BrowserContext) -> bool:
|
||||
local_storage = await self.playwright_page.evaluate("() => window.localStorage")
|
||||
if local_storage.get("HasUserLogin", "") == "1":
|
||||
return True
|
||||
|
||||
_, cookie_dict = utils.convert_cookies(await browser_context.cookies())
|
||||
# todo send some api to test login status
|
||||
return cookie_dict.get("LOGIN_STATUS") == "1"
|
||||
|
||||
async def update_cookies(self, browser_context: BrowserContext):
|
||||
|
|
|
@ -73,8 +73,19 @@ class DouYinLogin(AbstractLogin):
|
|||
"""Check if the current login status is successful and return True otherwise return False"""
|
||||
current_cookie = await self.browser_context.cookies()
|
||||
_, cookie_dict = utils.convert_cookies(current_cookie)
|
||||
|
||||
for page in self.browser_context.pages:
|
||||
try:
|
||||
local_storage = await page.evaluate("() => window.localStorage")
|
||||
if local_storage.get("HasUserLogin", "") == "1":
|
||||
return True
|
||||
except Exception as e:
|
||||
utils.logger.warn(f"[DouYinLogin] check_login_state waring: {e}")
|
||||
await asyncio.sleep(1)
|
||||
|
||||
if cookie_dict.get("LOGIN_STATUS") == "1":
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
async def popup_login_dialog(self):
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 175 KiB |
Binary file not shown.
After Width: | Height: | Size: 209 KiB |
Loading…
Reference in New Issue