fix search
This commit is contained in:
parent
137d952028
commit
77bc8ce8ee
@ -12,6 +12,7 @@ from app.core.metainfo import MetaInfo
|
|||||||
from app.db.systemconfig_oper import SystemConfigOper
|
from app.db.systemconfig_oper import SystemConfigOper
|
||||||
from app.helper.progress import ProgressHelper
|
from app.helper.progress import ProgressHelper
|
||||||
from app.helper.sites import SitesHelper
|
from app.helper.sites import SitesHelper
|
||||||
|
from app.helper.torrent import TorrentHelper
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.schemas import NotExistMediaInfo
|
from app.schemas import NotExistMediaInfo
|
||||||
from app.schemas.types import MediaType, ProgressKey, SystemConfigKey
|
from app.schemas.types import MediaType, ProgressKey, SystemConfigKey
|
||||||
@ -182,10 +183,14 @@ class SearchChain(ChainBase):
|
|||||||
else:
|
else:
|
||||||
_match_torrents = torrents
|
_match_torrents = torrents
|
||||||
logger.info(f"匹配完成,共匹配到 {len(_match_torrents)} 个资源")
|
logger.info(f"匹配完成,共匹配到 {len(_match_torrents)} 个资源")
|
||||||
# 组装上下文返回
|
# 组装上下文
|
||||||
return [Context(meta_info=MetaInfo(title=torrent.title, subtitle=torrent.description),
|
contexts = [Context(meta_info=MetaInfo(title=torrent.title, subtitle=torrent.description),
|
||||||
media_info=mediainfo,
|
media_info=mediainfo,
|
||||||
torrent_info=torrent) for torrent in _match_torrents]
|
torrent_info=torrent) for torrent in _match_torrents]
|
||||||
|
# 排序
|
||||||
|
contexts = TorrentHelper.sort_torrents(contexts)
|
||||||
|
# 返回
|
||||||
|
return contexts
|
||||||
|
|
||||||
def __search_all_sites(self, mediainfo: Optional[MediaInfo] = None,
|
def __search_all_sites(self, mediainfo: Optional[MediaInfo] = None,
|
||||||
keyword: str = None) -> Optional[List[TorrentInfo]]:
|
keyword: str = None) -> Optional[List[TorrentInfo]]:
|
||||||
|
@ -180,19 +180,19 @@ class TorrentHelper:
|
|||||||
_meta = _context.meta_info
|
_meta = _context.meta_info
|
||||||
_torrent = _context.torrent_info
|
_torrent = _context.torrent_info
|
||||||
# 站点优先级
|
# 站点优先级
|
||||||
_site_order = 999 - _torrent.site_order
|
_site_order = 999 - (_torrent.site_order or 0)
|
||||||
# 季数
|
# 季数
|
||||||
_season_len = str(len(_meta.season_list)).rjust(2, '0')
|
_season_len = str(len(_meta.season_list)).rjust(2, '0')
|
||||||
# 集数
|
# 集数
|
||||||
_episode_len = str(9999 - len(_meta.episode_list)).rjust(4, '0')
|
_episode_len = str(9999 - len(_meta.episode_list)).rjust(4, '0')
|
||||||
if settings.TORRENT_PRI == "seeder":
|
if settings.TORRENT_PRI != "site":
|
||||||
# 排序:标题、资源类型、站点、做种、季集
|
# 排序:标题、资源类型、做种、季集
|
||||||
return "%s%s%s%s" % (str(_torrent.title).ljust(100, ' '),
|
return "%s%s%s%s" % (str(_torrent.title).ljust(100, ' '),
|
||||||
str(_torrent.pri_order).rjust(3, '0'),
|
str(_torrent.pri_order).rjust(3, '0'),
|
||||||
str(_torrent.seeders).rjust(10, '0'),
|
str(_torrent.seeders).rjust(10, '0'),
|
||||||
"%s%s" % (_season_len, _episode_len))
|
"%s%s" % (_season_len, _episode_len))
|
||||||
else:
|
else:
|
||||||
# 排序:标题、资源类型、站点、季集、做种
|
# 排序:标题、资源类型、站点、做种、季集
|
||||||
return "%s%s%s%s%s" % (str(_torrent.title).ljust(100, ' '),
|
return "%s%s%s%s%s" % (str(_torrent.title).ljust(100, ' '),
|
||||||
str(_torrent.pri_order).rjust(3, '0'),
|
str(_torrent.pri_order).rjust(3, '0'),
|
||||||
str(_site_order).rjust(3, '0'),
|
str(_site_order).rjust(3, '0'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user