mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-07-07 07:41:28 +08:00
fix lint
This commit is contained in:
@@ -4,7 +4,7 @@ from pydantic import Field
|
|||||||
|
|
||||||
from app.actions import BaseAction, ActionChain
|
from app.actions import BaseAction, ActionChain
|
||||||
from app.schemas import ActionParams, ActionContext, Notification
|
from app.schemas import ActionParams, ActionContext, Notification
|
||||||
from core.config import settings
|
from app.core.config import settings
|
||||||
|
|
||||||
|
|
||||||
class SendMessageParams(ActionParams):
|
class SendMessageParams(ActionParams):
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ from app.core.event import eventmanager
|
|||||||
from app.core.security import verify_token
|
from app.core.security import verify_token
|
||||||
from app.schemas import DiscoverSourceEventData
|
from app.schemas import DiscoverSourceEventData
|
||||||
from app.schemas.types import ChainEventType, MediaType
|
from app.schemas.types import ChainEventType, MediaType
|
||||||
from chain.bangumi import BangumiChain
|
from app.chain.bangumi import BangumiChain
|
||||||
from chain.douban import DoubanChain
|
from app.chain.douban import DoubanChain
|
||||||
from chain.tmdb import TmdbChain
|
from app.chain.tmdb import TmdbChain
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ class CacheToolsBackend(CacheBackend):
|
|||||||
return None
|
return None
|
||||||
return region_cache.get(key)
|
return region_cache.get(key)
|
||||||
|
|
||||||
def delete(self, key: str, region: Optional[str] = DEFAULT_CACHE_REGION) -> None:
|
def delete(self, key: str, region: Optional[str] = DEFAULT_CACHE_REGION):
|
||||||
"""
|
"""
|
||||||
删除缓存
|
删除缓存
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ class CacheToolsBackend(CacheBackend):
|
|||||||
"""
|
"""
|
||||||
region_cache = self.__get_region_cache(region)
|
region_cache = self.__get_region_cache(region)
|
||||||
if region_cache is None:
|
if region_cache is None:
|
||||||
return None
|
return
|
||||||
with lock:
|
with lock:
|
||||||
del region_cache[key]
|
del region_cache[key]
|
||||||
|
|
||||||
|
|||||||
@@ -22,39 +22,36 @@ _executor = concurrent.futures.ThreadPoolExecutor()
|
|||||||
_doh_timeout = 5
|
_doh_timeout = 5
|
||||||
_doh_cache: Dict[str, str] = {}
|
_doh_cache: Dict[str, str] = {}
|
||||||
|
|
||||||
|
|
||||||
def _patched_getaddrinfo(host, *args, **kwargs):
|
|
||||||
"""
|
|
||||||
socket.getaddrinfo的补丁版本。
|
|
||||||
"""
|
|
||||||
if host not in settings.DOH_DOMAINS.split(","):
|
|
||||||
return _orig_getaddrinfo(host, *args, **kwargs)
|
|
||||||
|
|
||||||
# 检查主机是否已解析
|
|
||||||
if host in _doh_cache:
|
|
||||||
ip = _doh_cache[host]
|
|
||||||
logger.info("已解析 [%s] 为 [%s] (缓存)", host, ip)
|
|
||||||
return _orig_getaddrinfo(ip, *args, **kwargs)
|
|
||||||
|
|
||||||
# 使用DoH解析主机
|
|
||||||
futures = []
|
|
||||||
for resolver in settings.DOH_RESOLVERS.split(","):
|
|
||||||
futures.append(_executor.submit(_doh_query, resolver, host))
|
|
||||||
|
|
||||||
for future in concurrent.futures.as_completed(futures):
|
|
||||||
ip = future.result()
|
|
||||||
if ip is not None:
|
|
||||||
logger.info("已解析 [%s] 为 [%s]", host, ip)
|
|
||||||
_doh_cache[host] = ip
|
|
||||||
host = ip
|
|
||||||
break
|
|
||||||
|
|
||||||
return _orig_getaddrinfo(host, *args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
# 对 socket.getaddrinfo 进行补丁
|
# 对 socket.getaddrinfo 进行补丁
|
||||||
if settings.DOH_ENABLE:
|
if settings.DOH_ENABLE:
|
||||||
|
# 保存原始的 socket.getaddrinfo 方法
|
||||||
_orig_getaddrinfo = socket.getaddrinfo
|
_orig_getaddrinfo = socket.getaddrinfo
|
||||||
|
|
||||||
|
def _patched_getaddrinfo(host, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
socket.getaddrinfo的补丁版本。
|
||||||
|
"""
|
||||||
|
if host not in settings.DOH_DOMAINS.split(","):
|
||||||
|
return _orig_getaddrinfo(host, *args, **kwargs)
|
||||||
|
# 检查主机是否已解析
|
||||||
|
if host in _doh_cache:
|
||||||
|
ip = _doh_cache[host]
|
||||||
|
logger.info("已解析 [%s] 为 [%s] (缓存)", host, ip)
|
||||||
|
return _orig_getaddrinfo(ip, *args, **kwargs)
|
||||||
|
# 使用DoH解析主机
|
||||||
|
futures = []
|
||||||
|
for resolver in settings.DOH_RESOLVERS.split(","):
|
||||||
|
futures.append(_executor.submit(_doh_query, resolver, host))
|
||||||
|
for future in concurrent.futures.as_completed(futures):
|
||||||
|
ip = future.result()
|
||||||
|
if ip is not None:
|
||||||
|
logger.info("已解析 [%s] 为 [%s]", host, ip)
|
||||||
|
_doh_cache[host] = ip
|
||||||
|
host = ip
|
||||||
|
break
|
||||||
|
return _orig_getaddrinfo(host, *args, **kwargs)
|
||||||
|
|
||||||
|
# 替换 socket.getaddrinfo 方法
|
||||||
socket.getaddrinfo = _patched_getaddrinfo
|
socket.getaddrinfo = _patched_getaddrinfo
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user