fix no_exits
This commit is contained in:
parent
98a51f6ddc
commit
266b1d60a7
@ -307,13 +307,13 @@ class ChainBase(metaclass=ABCMeta):
|
|||||||
"""
|
"""
|
||||||
return self.run_module("stop_torrents", hashs=hashs)
|
return self.run_module("stop_torrents", hashs=hashs)
|
||||||
|
|
||||||
def media_exists(self, mediainfo: MediaInfo) -> Optional[ExistMediaInfo]:
|
def media_exists(self, mediainfo: MediaInfo, itemid: str) -> Optional[ExistMediaInfo]:
|
||||||
"""
|
"""
|
||||||
判断媒体文件是否存在
|
判断媒体文件是否存在
|
||||||
:param mediainfo: 识别的媒体信息
|
:param mediainfo: 识别的媒体信息
|
||||||
:return: 如不存在返回None,存在时返回信息,包括每季已存在所有集{type: movie/tv, seasons: {season: [episodes]}}
|
:return: 如不存在返回None,存在时返回信息,包括每季已存在所有集{type: movie/tv, seasons: {season: [episodes]}}
|
||||||
"""
|
"""
|
||||||
return self.run_module("media_exists", mediainfo=mediainfo)
|
return self.run_module("media_exists", mediainfo=mediainfo, itemid=itemid)
|
||||||
|
|
||||||
def refresh_mediaserver(self, mediainfo: MediaInfo, file_path: Path) -> Optional[bool]:
|
def refresh_mediaserver(self, mediainfo: MediaInfo, file_path: Path) -> Optional[bool]:
|
||||||
"""
|
"""
|
||||||
|
@ -7,9 +7,10 @@ from app.core.config import settings
|
|||||||
from app.core.context import MediaInfo, TorrentInfo, Context
|
from app.core.context import MediaInfo, TorrentInfo, Context
|
||||||
from app.core.meta import MetaBase
|
from app.core.meta import MetaBase
|
||||||
from app.db.downloadhistory_oper import DownloadHistoryOper
|
from app.db.downloadhistory_oper import DownloadHistoryOper
|
||||||
|
from app.db.mediaserver_oper import MediaServerOper
|
||||||
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
|
from app.schemas import ExistMediaInfo, NotExistMediaInfo, DownloadingTorrent, Notification, MediaServerItem
|
||||||
from app.schemas.types import MediaType, TorrentStatus, EventType, MessageChannel, NotificationType
|
from app.schemas.types import MediaType, TorrentStatus, EventType, MessageChannel, NotificationType
|
||||||
from app.utils.string import StringUtils
|
from app.utils.string import StringUtils
|
||||||
|
|
||||||
@ -23,6 +24,7 @@ class DownloadChain(ChainBase):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.torrent = TorrentHelper()
|
self.torrent = TorrentHelper()
|
||||||
self.downloadhis = DownloadHistoryOper()
|
self.downloadhis = DownloadHistoryOper()
|
||||||
|
self.mediaserver = MediaServerOper()
|
||||||
|
|
||||||
def post_download_message(self, meta: MetaBase, mediainfo: MediaInfo, torrent: TorrentInfo,
|
def post_download_message(self, meta: MetaBase, mediainfo: MediaInfo, torrent: TorrentInfo,
|
||||||
channel: MessageChannel = None,
|
channel: MessageChannel = None,
|
||||||
@ -514,7 +516,11 @@ class DownloadChain(ChainBase):
|
|||||||
logger.error(f"媒体信息中没有季集信息:{mediainfo.title_year}")
|
logger.error(f"媒体信息中没有季集信息:{mediainfo.title_year}")
|
||||||
return False, {}
|
return False, {}
|
||||||
# 电视剧
|
# 电视剧
|
||||||
exists_tvs: Optional[ExistMediaInfo] = self.media_exists(mediainfo)
|
mediaserveritem: Optional[MediaServerItem] = self.mediaserver.exists(mtype=mediainfo.type.value,
|
||||||
|
tmdbid=mediainfo.tmdb_id,
|
||||||
|
season=mediainfo.season)
|
||||||
|
item_id = str(mediaserveritem.item_id) if mediaserveritem and mediaserveritem.item_id else None
|
||||||
|
exists_tvs: Optional[ExistMediaInfo] = self.media_exists(mediainfo,item_id)
|
||||||
if not exists_tvs:
|
if not exists_tvs:
|
||||||
# 所有剧集均缺失
|
# 所有剧集均缺失
|
||||||
for season, episodes in mediainfo.seasons.items():
|
for season, episodes in mediainfo.seasons.items():
|
||||||
|
@ -42,7 +42,7 @@ class EmbyModule(_ModuleBase):
|
|||||||
"""
|
"""
|
||||||
return self.emby.get_webhook_message(form.get("data"))
|
return self.emby.get_webhook_message(form.get("data"))
|
||||||
|
|
||||||
def media_exists(self, mediainfo: MediaInfo) -> Optional[ExistMediaInfo]:
|
def media_exists(self, mediainfo: MediaInfo, itemid: str) -> Optional[ExistMediaInfo]:
|
||||||
"""
|
"""
|
||||||
判断媒体文件是否存在
|
判断媒体文件是否存在
|
||||||
:param mediainfo: 识别的媒体信息
|
:param mediainfo: 识别的媒体信息
|
||||||
@ -59,7 +59,8 @@ class EmbyModule(_ModuleBase):
|
|||||||
else:
|
else:
|
||||||
tvs = self.emby.get_tv_episodes(title=mediainfo.title,
|
tvs = self.emby.get_tv_episodes(title=mediainfo.title,
|
||||||
year=mediainfo.year,
|
year=mediainfo.year,
|
||||||
tmdb_id=mediainfo.tmdb_id)
|
tmdb_id=mediainfo.tmdb_id,
|
||||||
|
item_id=itemid)
|
||||||
if not tvs:
|
if not tvs:
|
||||||
logger.info(f"{mediainfo.title_year} 在媒体库中不存在")
|
logger.info(f"{mediainfo.title_year} 在媒体库中不存在")
|
||||||
return None
|
return None
|
||||||
|
@ -318,10 +318,10 @@ class Emby(metaclass=Singleton):
|
|||||||
if not item_id:
|
if not item_id:
|
||||||
return {}
|
return {}
|
||||||
# 验证tmdbid是否相同
|
# 验证tmdbid是否相同
|
||||||
item_tmdbid = self.get_iteminfo(item_id).get("ProviderIds", {}).get("Tmdb")
|
item_tmdbid = self.get_iteminfo(item_id).get("ProviderIds", {}).get("Tmdb")
|
||||||
if tmdb_id and item_tmdbid:
|
if tmdb_id and item_tmdbid:
|
||||||
if str(tmdb_id) != str(item_tmdbid):
|
if str(tmdb_id) != str(item_tmdbid):
|
||||||
return {}
|
return {}
|
||||||
# /Shows/Id/Episodes 查集的信息
|
# /Shows/Id/Episodes 查集的信息
|
||||||
if not season:
|
if not season:
|
||||||
season = ""
|
season = ""
|
||||||
|
@ -43,7 +43,7 @@ class JellyfinModule(_ModuleBase):
|
|||||||
"""
|
"""
|
||||||
return self.jellyfin.get_webhook_message(json.loads(body))
|
return self.jellyfin.get_webhook_message(json.loads(body))
|
||||||
|
|
||||||
def media_exists(self, mediainfo: MediaInfo) -> Optional[ExistMediaInfo]:
|
def media_exists(self, mediainfo: MediaInfo, itemid: str) -> Optional[ExistMediaInfo]:
|
||||||
"""
|
"""
|
||||||
判断媒体文件是否存在
|
判断媒体文件是否存在
|
||||||
:param mediainfo: 识别的媒体信息
|
:param mediainfo: 识别的媒体信息
|
||||||
@ -60,7 +60,8 @@ class JellyfinModule(_ModuleBase):
|
|||||||
else:
|
else:
|
||||||
tvs = self.jellyfin.get_tv_episodes(title=mediainfo.title,
|
tvs = self.jellyfin.get_tv_episodes(title=mediainfo.title,
|
||||||
year=mediainfo.year,
|
year=mediainfo.year,
|
||||||
tmdb_id=mediainfo.tmdb_id)
|
tmdb_id=mediainfo.tmdb_id,
|
||||||
|
item_id=itemid)
|
||||||
if not tvs:
|
if not tvs:
|
||||||
logger.info(f"{mediainfo.title_year} 在媒体库中不存在")
|
logger.info(f"{mediainfo.title_year} 在媒体库中不存在")
|
||||||
return None
|
return None
|
||||||
|
@ -293,10 +293,10 @@ class Jellyfin(metaclass=Singleton):
|
|||||||
if not item_id:
|
if not item_id:
|
||||||
return {}
|
return {}
|
||||||
# 验证tmdbid是否相同
|
# 验证tmdbid是否相同
|
||||||
item_tmdbid = self.get_iteminfo(item_id).get("ProviderIds", {}).get("Tmdb")
|
item_tmdbid = self.get_iteminfo(item_id).get("ProviderIds", {}).get("Tmdb")
|
||||||
if tmdb_id and item_tmdbid:
|
if tmdb_id and item_tmdbid:
|
||||||
if str(tmdb_id) != str(item_tmdbid):
|
if str(tmdb_id) != str(item_tmdbid):
|
||||||
return {}
|
return {}
|
||||||
if not season:
|
if not season:
|
||||||
season = ""
|
season = ""
|
||||||
try:
|
try:
|
||||||
|
@ -33,7 +33,7 @@ class PlexModule(_ModuleBase):
|
|||||||
"""
|
"""
|
||||||
return self.plex.get_webhook_message(form.get("payload"))
|
return self.plex.get_webhook_message(form.get("payload"))
|
||||||
|
|
||||||
def media_exists(self, mediainfo: MediaInfo) -> Optional[ExistMediaInfo]:
|
def media_exists(self, mediainfo: MediaInfo, itemid: str) -> Optional[ExistMediaInfo]:
|
||||||
"""
|
"""
|
||||||
判断媒体文件是否存在
|
判断媒体文件是否存在
|
||||||
:param mediainfo: 识别的媒体信息
|
:param mediainfo: 识别的媒体信息
|
||||||
|
Loading…
x
Reference in New Issue
Block a user