fix indexer sites
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import json
|
||||
import json
|
||||
import time
|
||||
from typing import Any
|
||||
from typing import Any, List
|
||||
|
||||
from fastapi import APIRouter, HTTPException, Depends
|
||||
from fastapi.responses import StreamingResponse
|
||||
@ -37,16 +37,18 @@ def get_progress(process_type: str, token: str):
|
||||
return StreamingResponse(event_generator(), media_type="text/event-stream")
|
||||
|
||||
|
||||
@router.get("/setting", summary="查询系统设置")
|
||||
@router.get("/setting/{key}", summary="查询系统设置")
|
||||
def get_setting(key: str, _: schemas.TokenPayload = Depends(verify_token)):
|
||||
"""
|
||||
查询系统设置
|
||||
"""
|
||||
return schemas.Response(success=True, data=SystemConfigOper().get(key))
|
||||
return schemas.Response(success=True, data={
|
||||
"value": SystemConfigOper().get(key)
|
||||
})
|
||||
|
||||
|
||||
@router.put("/setting", summary="更新系统设置")
|
||||
def set_setting(key: str, value: Any, _: schemas.TokenPayload = Depends(verify_token)):
|
||||
@router.post("/setting/{key}", summary="更新系统设置")
|
||||
def set_setting(key: str, value: List[int], _: schemas.TokenPayload = Depends(verify_token)):
|
||||
"""
|
||||
更新系统设置
|
||||
"""
|
||||
|
@ -202,9 +202,11 @@ class SearchChain(ChainBase):
|
||||
"""
|
||||
# 未开启的站点不搜索
|
||||
indexer_sites = []
|
||||
# 配置的索引站点
|
||||
config_indexers = self.systemconfig.get(SystemConfigKey.IndexerSites) or []
|
||||
for indexer in self.siteshelper.get_indexers():
|
||||
if not settings.INDEXER_SITES \
|
||||
or any([s in indexer.get("domain") for s in settings.INDEXER_SITES.split(',')]):
|
||||
# 检查站点索引开关
|
||||
if not config_indexers or indexer.get("id") in config_indexers:
|
||||
# 站点流控
|
||||
state, msg = self.siteshelper.check(indexer.get("domain"))
|
||||
if not state:
|
||||
|
@ -11,12 +11,13 @@ from app.core.context import TorrentInfo, Context, MediaInfo
|
||||
from app.core.config import settings
|
||||
from app.db.models.subscribe import Subscribe
|
||||
from app.db.subscribe_oper import SubscribeOper
|
||||
from app.db.systemconfig_oper import SystemConfigOper
|
||||
from app.helper.message import MessageHelper
|
||||
from app.helper.sites import SitesHelper
|
||||
from app.log import logger
|
||||
from app.schemas import NotExistMediaInfo
|
||||
from app.utils.string import StringUtils
|
||||
from app.schemas.types import MediaType
|
||||
from app.schemas.types import MediaType, SystemConfigKey
|
||||
|
||||
|
||||
class SubscribeChain(ChainBase):
|
||||
@ -34,6 +35,7 @@ class SubscribeChain(ChainBase):
|
||||
self.subscribehelper = SubscribeOper()
|
||||
self.siteshelper = SitesHelper()
|
||||
self.message = MessageHelper()
|
||||
self.systemconfig = SystemConfigOper()
|
||||
|
||||
def add(self, title: str, year: str,
|
||||
mtype: MediaType = None,
|
||||
@ -269,11 +271,12 @@ class SubscribeChain(ChainBase):
|
||||
"""
|
||||
# 所有站点索引
|
||||
indexers = self.siteshelper.get_indexers()
|
||||
# 配置的索引站点
|
||||
config_indexers = self.systemconfig.get(SystemConfigKey.IndexerSites) or []
|
||||
# 遍历站点缓存资源
|
||||
for indexer in indexers:
|
||||
# 未开启的站点不搜索
|
||||
if settings.INDEXER_SITES \
|
||||
and not any([s in indexer.get("domain") for s in settings.INDEXER_SITES.split(',')]):
|
||||
if config_indexers and indexer.get("id") not in config_indexers:
|
||||
continue
|
||||
logger.info(f'开始刷新站点资源,站点:{indexer.get("name")} ...')
|
||||
domain = StringUtils.get_url_domain(indexer.get("domain"))
|
||||
|
@ -59,8 +59,6 @@ class Settings(BaseSettings):
|
||||
RMT_AUDIO_TRACK_EXT: list = ['.mka']
|
||||
# 索引器
|
||||
INDEXER: str = "builtin"
|
||||
# 索引站点,站点域名关键字使用,分隔
|
||||
INDEXER_SITES: str = ""
|
||||
# 用户认证站点 hhclub/audiences/hddolby/zmpt/freefarm/hdfans/wintersakura/leaves/1ptba/icc2022/iyuu
|
||||
AUTH_SITE: str = ""
|
||||
# 消息通知渠道 telegram/wechat/slack
|
||||
|
@ -36,6 +36,8 @@ class SystemConfigKey(Enum):
|
||||
UserInstalledPlugins = "UserInstalledPlugins"
|
||||
# 搜索结果
|
||||
SearchResults = "SearchResults"
|
||||
# 索引站点范围
|
||||
IndexerSites = "IndexerSites"
|
||||
|
||||
|
||||
# 站点框架
|
||||
|
Reference in New Issue
Block a user