This commit is contained in:
jxxghp 2024-03-16 20:40:02 +08:00
parent d917b00055
commit e4b90ca8f7
2 changed files with 20 additions and 26 deletions

View File

@ -40,9 +40,7 @@ class SiteChain(ChainBase):
self.rsshelper = RssHelper() self.rsshelper = RssHelper()
self.cookiehelper = CookieHelper() self.cookiehelper = CookieHelper()
self.message = MessageHelper() self.message = MessageHelper()
self.cookiecloud = CookieCloudHelper( self.cookiecloud = CookieCloudHelper()
settings=settings
)
# 特殊站点登录验证 # 特殊站点登录验证
self.special_site_test = { self.special_site_test = {

View File

@ -1,26 +1,22 @@
import os
import json import json
import os
from typing import Any, Dict, Tuple, Optional
from hashlib import md5 from hashlib import md5
from typing import Any, Dict, Tuple, Optional
from app.core.config import Settings, settings from app.core.config import settings
from app.utils.common import decrypt
from app.utils.http import RequestUtils from app.utils.http import RequestUtils
from app.utils.string import StringUtils from app.utils.string import StringUtils
from app.utils.common import decrypt
class CookieCloudHelper: class CookieCloudHelper:
_ignore_cookies: list = ["CookieAutoDeleteBrowsingDataCleanup", "CookieAutoDeleteCleaningDiscarded"] _ignore_cookies: list = ["CookieAutoDeleteBrowsingDataCleanup", "CookieAutoDeleteCleaningDiscarded"]
def __init__(self, settings: Settings): def __init__(self):
self._setting = settings
self._sync_setting() self._sync_setting()
self._req = RequestUtils(content_type="application/json") self._req = RequestUtils(content_type="application/json")
def _sync_setting(self): def _sync_setting(self):
if self._setting:
self._server = settings.COOKIECLOUD_HOST self._server = settings.COOKIECLOUD_HOST
self._key = settings.COOKIECLOUD_KEY self._key = settings.COOKIECLOUD_KEY
self._password = settings.COOKIECLOUD_PASSWORD self._password = settings.COOKIECLOUD_PASSWORD
@ -35,11 +31,11 @@ class CookieCloudHelper:
# 更新为最新设置 # 更新为最新设置
self._sync_setting() self._sync_setting()
if (not self._server and if ((not self._server and not self._enable_local)
not self._enable_local) or not self._key or not self._password: or not self._key
or not self._password):
return None, "CookieCloud参数不正确" return None, "CookieCloud参数不正确"
result = None
if self._enable_local: if self._enable_local:
# 开启本地服务时,从本地直接读取数据 # 开启本地服务时,从本地直接读取数据
result = self._load_local_encrypt_data(self._key) result = self._load_local_encrypt_data(self._key)