fix bug
This commit is contained in:
parent
8b8142ab60
commit
699fa3fa19
@ -171,7 +171,7 @@ class DownloadChain(ChainBase):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
# 分组排序
|
# 分组排序
|
||||||
contexts = TorrentHelper.sort_group_torrents(contexts)
|
contexts = TorrentHelper().sort_group_torrents(contexts)
|
||||||
|
|
||||||
# 如果是电影,直接下载
|
# 如果是电影,直接下载
|
||||||
for context in contexts:
|
for context in contexts:
|
||||||
|
@ -97,6 +97,7 @@ class UserMessageChain(ChainBase):
|
|||||||
logger.info(f"{mediainfo.get_title_string()} 媒体库中不存在,开始搜索 ...")
|
logger.info(f"{mediainfo.get_title_string()} 媒体库中不存在,开始搜索 ...")
|
||||||
self.post_message(
|
self.post_message(
|
||||||
title=f"开始搜索 {mediainfo.type.value} {mediainfo.get_title_string()} ...", userid=userid)
|
title=f"开始搜索 {mediainfo.type.value} {mediainfo.get_title_string()} ...", userid=userid)
|
||||||
|
# 开始搜索
|
||||||
contexts = self.searchchain.process(meta=self._current_meta,
|
contexts = self.searchchain.process(meta=self._current_meta,
|
||||||
mediainfo=mediainfo,
|
mediainfo=mediainfo,
|
||||||
no_exists=no_exists)
|
no_exists=no_exists)
|
||||||
@ -104,6 +105,8 @@ class UserMessageChain(ChainBase):
|
|||||||
# 没有数据
|
# 没有数据
|
||||||
self.post_message(title=f"{mediainfo.title} 未搜索到资源!", userid=userid)
|
self.post_message(title=f"{mediainfo.title} 未搜索到资源!", userid=userid)
|
||||||
return
|
return
|
||||||
|
# 搜索结果排序
|
||||||
|
|
||||||
# 更新缓存
|
# 更新缓存
|
||||||
self._user_cache[userid] = {
|
self._user_cache[userid] = {
|
||||||
"type": "Torrent",
|
"type": "Torrent",
|
||||||
|
@ -149,9 +149,9 @@ class TorrentHelper:
|
|||||||
return file_name
|
return file_name
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def sort_group_torrents(torrent_list: List[Context]) -> List[Context]:
|
def sort_torrents(torrent_list: List[Context]) -> List[Context]:
|
||||||
"""
|
"""
|
||||||
对媒体信息进行排序、去重
|
对种子对行排序
|
||||||
"""
|
"""
|
||||||
if not torrent_list:
|
if not torrent_list:
|
||||||
return []
|
return []
|
||||||
@ -171,6 +171,19 @@ class TorrentHelper:
|
|||||||
# 匹配的资源中排序分组选最好的一个下载
|
# 匹配的资源中排序分组选最好的一个下载
|
||||||
# 按站点顺序、资源匹配顺序、做种人数下载数逆序排序
|
# 按站点顺序、资源匹配顺序、做种人数下载数逆序排序
|
||||||
torrent_list = sorted(torrent_list, key=lambda x: get_sort_str(x), reverse=True)
|
torrent_list = sorted(torrent_list, key=lambda x: get_sort_str(x), reverse=True)
|
||||||
|
|
||||||
|
return torrent_list
|
||||||
|
|
||||||
|
def sort_group_torrents(self, torrent_list: List[Context]) -> List[Context]:
|
||||||
|
"""
|
||||||
|
对媒体信息进行排序、去重
|
||||||
|
"""
|
||||||
|
if not torrent_list:
|
||||||
|
return []
|
||||||
|
|
||||||
|
# 排序
|
||||||
|
torrent_list = self.sort_torrents(torrent_list)
|
||||||
|
|
||||||
# 控重
|
# 控重
|
||||||
result = []
|
result = []
|
||||||
_added = []
|
_added = []
|
||||||
|
@ -116,11 +116,13 @@ class FilterModule(_ModuleBase):
|
|||||||
if not torrent_episodes:
|
if not torrent_episodes:
|
||||||
# 整季按匹配处理
|
# 整季按匹配处理
|
||||||
return True
|
return True
|
||||||
if len(torrent_episodes) == 1 \
|
if len(torrent_seasons) == 1:
|
||||||
and not set(torrent_seasons).intersection(set(season_episodes.get(torrent_seasons[0]))):
|
need_episodes = season_episodes.get(torrent_seasons[0])
|
||||||
# 单季集没有交集的不要
|
if need_episodes \
|
||||||
logger.info(f"种子 {torrent.title} 集 {torrent_episodes} 没有需要的集")
|
and not set(torrent_seasons).intersection(set(need_episodes)):
|
||||||
return False
|
# 单季集没有交集的不要
|
||||||
|
logger.info(f"种子 {torrent.title} 集 {torrent_episodes} 没有需要的集")
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def __get_order(self, torrent: TorrentInfo, rule_str: str) -> Optional[TorrentInfo]:
|
def __get_order(self, torrent: TorrentInfo, rule_str: str) -> Optional[TorrentInfo]:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import re
|
||||||
import threading
|
import threading
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from threading import Event
|
from threading import Event
|
||||||
@ -9,6 +10,7 @@ from telebot.types import InputFile
|
|||||||
|
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.context import MediaInfo, Context
|
from app.core.context import MediaInfo, Context
|
||||||
|
from app.core.metainfo import MetaInfo
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.utils.http import RequestUtils
|
from app.utils.http import RequestUtils
|
||||||
from app.utils.singleton import Singleton
|
from app.utils.singleton import Singleton
|
||||||
@ -140,8 +142,12 @@ class Telegram(metaclass=Singleton):
|
|||||||
for context in torrents:
|
for context in torrents:
|
||||||
torrent = context.torrent_info
|
torrent = context.torrent_info
|
||||||
site_name = torrent.site_name
|
site_name = torrent.site_name
|
||||||
|
meta = MetaInfo(torrent.title, torrent.description)
|
||||||
link = torrent.page_url
|
link = torrent.page_url
|
||||||
title = torrent.title
|
title = f"{meta.get_season_episode_string()} " \
|
||||||
|
f"{meta.get_resource_type_string()} " \
|
||||||
|
f"{meta.get_resource_team_string()}"
|
||||||
|
title = re.sub(r"\s+", " ", title).strip()
|
||||||
free = torrent.get_volume_factor_string()
|
free = torrent.get_volume_factor_string()
|
||||||
seeder = f"{torrent.seeders}↑"
|
seeder = f"{torrent.seeders}↑"
|
||||||
description = torrent.description
|
description = torrent.description
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
|
import re
|
||||||
import threading
|
import threading
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional, List
|
from typing import Optional, List
|
||||||
@ -211,11 +212,13 @@ class WeChat(metaclass=Singleton):
|
|||||||
for context in torrents:
|
for context in torrents:
|
||||||
torrent = context.torrent_info
|
torrent = context.torrent_info
|
||||||
meta = MetaInfo(title=torrent.title, subtitle=torrent.description)
|
meta = MetaInfo(title=torrent.title, subtitle=torrent.description)
|
||||||
torrent_title = f"【{torrent.site_name}】" \
|
torrent_title = f"{index}.【{torrent.site_name}】" \
|
||||||
f"{meta.get_season_episode_string()} " \
|
f"{meta.get_season_episode_string()} " \
|
||||||
f"{meta.get_resource_type_string()} " \
|
f"{meta.get_resource_type_string()} " \
|
||||||
|
f"{meta.get_resource_team_string()}" \
|
||||||
f"{torrent.get_volume_factor_string()} " \
|
f"{torrent.get_volume_factor_string()} " \
|
||||||
f"{torrent.seeders}↑"
|
f"{torrent.seeders}↑"
|
||||||
|
title = re.sub(r"\s+", " ", title).strip()
|
||||||
articles.append({
|
articles.append({
|
||||||
"title": torrent_title,
|
"title": torrent_title,
|
||||||
"description": torrent.description if index == 1 else '',
|
"description": torrent.description if index == 1 else '',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user