mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
fix #4382
This commit is contained in:
@@ -19,8 +19,10 @@ from app.helper.directory import DirectoryHelper
|
|||||||
from app.helper.message import MessageHelper
|
from app.helper.message import MessageHelper
|
||||||
from app.helper.torrent import TorrentHelper
|
from app.helper.torrent import TorrentHelper
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.schemas import ExistMediaInfo, NotExistMediaInfo, DownloadingTorrent, Notification, ResourceSelectionEventData, ResourceDownloadEventData
|
from app.schemas import ExistMediaInfo, NotExistMediaInfo, DownloadingTorrent, Notification, ResourceSelectionEventData, \
|
||||||
from app.schemas.types import MediaType, TorrentStatus, EventType, MessageChannel, NotificationType, ContentType, ChainEventType
|
ResourceDownloadEventData
|
||||||
|
from app.schemas.types import MediaType, TorrentStatus, EventType, MessageChannel, NotificationType, ContentType, \
|
||||||
|
ChainEventType
|
||||||
from app.utils.http import RequestUtils
|
from app.utils.http import RequestUtils
|
||||||
from app.utils.string import StringUtils
|
from app.utils.string import StringUtils
|
||||||
|
|
||||||
@@ -450,6 +452,7 @@ class DownloadChain(ChainBase):
|
|||||||
if not no_exist.get(season):
|
if not no_exist.get(season):
|
||||||
return 9999
|
return 9999
|
||||||
return no_exist[season].total_episode
|
return no_exist[season].total_episode
|
||||||
|
|
||||||
def _calculate_intersection_ratio(episodes_set: set, target_set: set) -> Tuple[float, set]:
|
def _calculate_intersection_ratio(episodes_set: set, target_set: set) -> Tuple[float, set]:
|
||||||
"""
|
"""
|
||||||
计算种子与目标缺失集之间的交集比例。
|
计算种子与目标缺失集之间的交集比例。
|
||||||
@@ -462,6 +465,7 @@ class DownloadChain(ChainBase):
|
|||||||
return 0.0, set()
|
return 0.0, set()
|
||||||
cal_ratio = len(cal_intersection) / len(episodes_set)
|
cal_ratio = len(cal_intersection) / len(episodes_set)
|
||||||
return cal_ratio, cal_intersection
|
return cal_ratio, cal_intersection
|
||||||
|
|
||||||
# 发送资源选择事件,允许外部修改上下文数据
|
# 发送资源选择事件,允许外部修改上下文数据
|
||||||
logger.debug(f"Initial contexts: {len(contexts)} items, Downloader: {downloader}")
|
logger.debug(f"Initial contexts: {len(contexts)} items, Downloader: {downloader}")
|
||||||
event_data = ResourceSelectionEventData(
|
event_data = ResourceSelectionEventData(
|
||||||
@@ -651,7 +655,7 @@ class DownloadChain(ChainBase):
|
|||||||
# 计算交集
|
# 计算交集
|
||||||
# 若种子[5-10],[7-10],[9-10] need_episodes=[9,10,11,12,13,14]
|
# 若种子[5-10],[7-10],[9-10] need_episodes=[9,10,11,12,13,14]
|
||||||
# 计算后的交集比例( len(torrent_episodes ∩ need_episodes) / len(torrent_episodes) )分别 0.33 0.66 1.0
|
# 计算后的交集比例( len(torrent_episodes ∩ need_episodes) / len(torrent_episodes) )分别 0.33 0.66 1.0
|
||||||
ratio, intersection = _calculate_intersection_ratio(torrent_episodes,set(need_episodes))
|
ratio, intersection = _calculate_intersection_ratio(torrent_episodes, set(need_episodes))
|
||||||
if ratio <= (settings.EPISODE_INTERSECTION_MIN_CONFIDENCE or 0.05):
|
if ratio <= (settings.EPISODE_INTERSECTION_MIN_CONFIDENCE or 0.05):
|
||||||
# 可以设定阈值
|
# 可以设定阈值
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|||||||
@@ -569,15 +569,14 @@ class SubscribeChain(ChainBase, metaclass=Singleton):
|
|||||||
for context in contexts:
|
for context in contexts:
|
||||||
# 复制上下文避免修改原始数据
|
# 复制上下文避免修改原始数据
|
||||||
_context = copy.deepcopy(context)
|
_context = copy.deepcopy(context)
|
||||||
torrent_meta = _context.meta_info
|
|
||||||
torrent_mediainfo = _context.media_info
|
|
||||||
|
|
||||||
# 如果种子未识别,尝试识别
|
# 如果种子未识别,尝试识别
|
||||||
if not torrent_mediainfo or (not torrent_mediainfo.tmdb_id and not torrent_mediainfo.douban_id):
|
if not _context.media_info or (not _context.media_info.tmdb_id
|
||||||
torrent_mediainfo = self.recognize_media(meta=torrent_meta)
|
and not _context.media_info.douban_id):
|
||||||
if torrent_mediainfo:
|
re_mediainfo = self.recognize_media(meta=_context.meta_info)
|
||||||
|
if re_mediainfo:
|
||||||
# 更新种子缓存
|
# 更新种子缓存
|
||||||
context.media_info = torrent_mediainfo
|
_context.media_info = re_mediainfo
|
||||||
|
context.media_info = re_mediainfo
|
||||||
# 添加已预处理
|
# 添加已预处理
|
||||||
processed_torrents[domain].append(_context)
|
processed_torrents[domain].append(_context)
|
||||||
|
|
||||||
@@ -657,12 +656,14 @@ class SubscribeChain(ChainBase, metaclass=Singleton):
|
|||||||
torrent_meta = MetaInfo(title=torrent_info.title, subtitle=torrent_info.description,
|
torrent_meta = MetaInfo(title=torrent_info.title, subtitle=torrent_info.description,
|
||||||
custom_words=custom_words_list)
|
custom_words=custom_words_list)
|
||||||
# 更新元数据缓存
|
# 更新元数据缓存
|
||||||
|
_context.meta_info = torrent_meta
|
||||||
context.meta_info = torrent_meta
|
context.meta_info = torrent_meta
|
||||||
# 重新识别媒体信息
|
# 重新识别媒体信息
|
||||||
torrent_mediainfo = self.recognize_media(meta=torrent_meta,
|
torrent_mediainfo = self.recognize_media(meta=torrent_meta,
|
||||||
episode_group=subscribe.episode_group)
|
episode_group=subscribe.episode_group)
|
||||||
if torrent_mediainfo:
|
if torrent_mediainfo:
|
||||||
# 更新种子缓存
|
# 更新种子缓存
|
||||||
|
_context.media_info = torrent_mediainfo
|
||||||
context.media_info = torrent_mediainfo
|
context.media_info = torrent_mediainfo
|
||||||
|
|
||||||
# 如果仍然没有识别到媒体信息,尝试标题匹配
|
# 如果仍然没有识别到媒体信息,尝试标题匹配
|
||||||
@@ -677,6 +678,7 @@ class SubscribeChain(ChainBase, metaclass=Singleton):
|
|||||||
f'{mediainfo.title_year} 通过标题匹配到可选资源:{torrent_info.site_name} - {torrent_info.title}')
|
f'{mediainfo.title_year} 通过标题匹配到可选资源:{torrent_info.site_name} - {torrent_info.title}')
|
||||||
torrent_mediainfo = mediainfo
|
torrent_mediainfo = mediainfo
|
||||||
# 更新种子缓存
|
# 更新种子缓存
|
||||||
|
_context.media_info = mediainfo
|
||||||
context.media_info = mediainfo
|
context.media_info = mediainfo
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|||||||
+2
-2
@@ -6,7 +6,7 @@ import secrets
|
|||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List, Optional, Tuple, Type, Union
|
from typing import Any, Dict, List, Optional, Tuple, Type
|
||||||
|
|
||||||
from dotenv import set_key
|
from dotenv import set_key
|
||||||
from pydantic import BaseModel, BaseSettings, validator, Field
|
from pydantic import BaseModel, BaseSettings, validator, Field
|
||||||
@@ -124,7 +124,7 @@ class ConfigModel(BaseModel):
|
|||||||
# 元数据识别缓存过期时间(小时)
|
# 元数据识别缓存过期时间(小时)
|
||||||
META_CACHE_EXPIRE: int = 0
|
META_CACHE_EXPIRE: int = 0
|
||||||
# 电视剧动漫的分类genre_ids
|
# 电视剧动漫的分类genre_ids
|
||||||
ANIME_GENREIDS: list[int] = [16]
|
ANIME_GENREIDS: List[int] = [16]
|
||||||
# 用户认证站点
|
# 用户认证站点
|
||||||
AUTH_SITE: str = ""
|
AUTH_SITE: str = ""
|
||||||
# 重启自动升级
|
# 重启自动升级
|
||||||
|
|||||||
Reference in New Issue
Block a user