fix bugs
This commit is contained in:
parent
812dc991e3
commit
3f6bb2b381
@ -1,7 +1,7 @@
|
||||
import json
|
||||
import json
|
||||
import time
|
||||
from typing import Any, List
|
||||
from typing import Any, List, Union
|
||||
|
||||
from fastapi import APIRouter, HTTPException, Depends
|
||||
from fastapi.responses import StreamingResponse
|
||||
@ -48,7 +48,8 @@ def get_setting(key: str, _: schemas.TokenPayload = Depends(verify_token)):
|
||||
|
||||
|
||||
@router.post("/setting/{key}", summary="更新系统设置")
|
||||
def set_setting(key: str, value: List[int], _: schemas.TokenPayload = Depends(verify_token)):
|
||||
def set_setting(key: str, value: Union[list, dict, str, int],
|
||||
_: schemas.TokenPayload = Depends(verify_token)):
|
||||
"""
|
||||
更新系统设置
|
||||
"""
|
||||
|
@ -33,6 +33,7 @@ class MessageChain(ChainBase):
|
||||
self.medtachain = MediaChain()
|
||||
self.torrent = TorrentHelper()
|
||||
self.eventmanager = EventManager()
|
||||
self.torrenthelper = TorrentHelper()
|
||||
|
||||
def process(self, body: Any, form: Any, args: Any) -> None:
|
||||
"""
|
||||
@ -111,7 +112,7 @@ class MessageChain(ChainBase):
|
||||
userid=userid)
|
||||
return
|
||||
# 搜索结果排序
|
||||
contexts = TorrentHelper.sort_torrents(contexts)
|
||||
contexts = self.torrenthelper.sort_torrents(contexts)
|
||||
# 更新缓存
|
||||
self._user_cache[userid] = {
|
||||
"type": "Torrent",
|
||||
|
@ -29,6 +29,7 @@ class SearchChain(ChainBase):
|
||||
self.siteshelper = SitesHelper()
|
||||
self.progress = ProgressHelper()
|
||||
self.systemconfig = SystemConfigOper()
|
||||
self.torrenthelper = TorrentHelper()
|
||||
|
||||
def search_by_tmdbid(self, tmdbid: int, mtype: MediaType = None) -> Optional[List[Context]]:
|
||||
"""
|
||||
@ -188,7 +189,7 @@ class SearchChain(ChainBase):
|
||||
media_info=mediainfo,
|
||||
torrent_info=torrent) for torrent in _match_torrents]
|
||||
# 排序
|
||||
contexts = TorrentHelper.sort_torrents(contexts)
|
||||
contexts = self.torrenthelper.sort_torrents(contexts)
|
||||
# 返回
|
||||
return contexts
|
||||
|
||||
|
@ -10,9 +10,10 @@ from torrentool.api import Torrent
|
||||
from app.core.config import settings
|
||||
from app.core.context import Context
|
||||
from app.core.metainfo import MetaInfo
|
||||
from app.db.systemconfig_oper import SystemConfigOper
|
||||
from app.log import logger
|
||||
from app.utils.http import RequestUtils
|
||||
from app.schemas.types import MediaType
|
||||
from app.schemas.types import MediaType, SystemConfigKey
|
||||
|
||||
|
||||
class TorrentHelper:
|
||||
@ -20,6 +21,9 @@ class TorrentHelper:
|
||||
种子帮助类
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.system_config = SystemConfigOper()
|
||||
|
||||
def download_torrent(self, url: str,
|
||||
cookie: str = None,
|
||||
ua: str = None,
|
||||
@ -165,8 +169,7 @@ class TorrentHelper:
|
||||
file_name = str(datetime.datetime.now())
|
||||
return file_name
|
||||
|
||||
@staticmethod
|
||||
def sort_torrents(torrent_list: List[Context]) -> List[Context]:
|
||||
def sort_torrents(self, torrent_list: List[Context]) -> List[Context]:
|
||||
"""
|
||||
对种子对行排序
|
||||
"""
|
||||
@ -185,7 +188,9 @@ class TorrentHelper:
|
||||
_season_len = str(len(_meta.season_list)).rjust(2, '0')
|
||||
# 集数
|
||||
_episode_len = str(9999 - len(_meta.episode_list)).rjust(4, '0')
|
||||
if settings.TORRENT_PRI != "site":
|
||||
# 优先规则
|
||||
priority = self.system_config.get(SystemConfigKey.TorrentsPriority)
|
||||
if priority != "site":
|
||||
# 排序:标题、资源类型、做种、季集
|
||||
return "%s%s%s%s" % (str(_torrent.title).ljust(100, ' '),
|
||||
str(_torrent.pri_order).rjust(3, '0'),
|
||||
|
@ -38,6 +38,8 @@ class SystemConfigKey(Enum):
|
||||
SearchResults = "SearchResults"
|
||||
# 索引站点范围
|
||||
IndexerSites = "IndexerSites"
|
||||
# 种子优先级规则
|
||||
TorrentsPriority = "TorrentsPriority"
|
||||
|
||||
|
||||
# 站点框架
|
||||
|
Loading…
x
Reference in New Issue
Block a user