fix bug
This commit is contained in:
parent
cf301f11ad
commit
4061fd21c8
@ -330,7 +330,7 @@ class DownloadChain(ChainBase):
|
|||||||
:return: 当前媒体是否缺失,各标题总的季集和缺失的季集
|
:return: 当前媒体是否缺失,各标题总的季集和缺失的季集
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __append_no_exists(_season: int, _episodes: list, _start: int, _total: int):
|
def __append_no_exists(_season: int, _episodes: list, _total: int, _start: int):
|
||||||
"""
|
"""
|
||||||
添加不存在的季集信息
|
添加不存在的季集信息
|
||||||
"""
|
"""
|
||||||
@ -367,6 +367,7 @@ class DownloadChain(ChainBase):
|
|||||||
mtype=mediainfo.type,
|
mtype=mediainfo.type,
|
||||||
tmdbid=mediainfo.tmdb_id)
|
tmdbid=mediainfo.tmdb_id)
|
||||||
if not mediainfo:
|
if not mediainfo:
|
||||||
|
logger.error(f"媒体信息识别失败!")
|
||||||
return False, {}
|
return False, {}
|
||||||
if not mediainfo.seasons:
|
if not mediainfo.seasons:
|
||||||
logger.error(f"媒体信息中没有季集信息:{mediainfo.get_title_string()}")
|
logger.error(f"媒体信息中没有季集信息:{mediainfo.get_title_string()}")
|
||||||
@ -377,7 +378,7 @@ class DownloadChain(ChainBase):
|
|||||||
# 所有剧集均缺失
|
# 所有剧集均缺失
|
||||||
for season, episodes in mediainfo.seasons.items():
|
for season, episodes in mediainfo.seasons.items():
|
||||||
# 全季不存在
|
# 全季不存在
|
||||||
__append_no_exists(season, [], len(episodes), min(episodes))
|
__append_no_exists(_season=season, _episodes=[], _total=len(episodes), _start=min(episodes))
|
||||||
return False, no_exists
|
return False, no_exists
|
||||||
else:
|
else:
|
||||||
# 存在一些,检查缺失的季集
|
# 存在一些,检查缺失的季集
|
||||||
@ -390,10 +391,12 @@ class DownloadChain(ChainBase):
|
|||||||
# 全部集存在
|
# 全部集存在
|
||||||
continue
|
continue
|
||||||
# 添加不存在的季集信息
|
# 添加不存在的季集信息
|
||||||
__append_no_exists(season, episodes, len(episodes), min(episodes))
|
__append_no_exists(_season=season, _episodes=episodes,
|
||||||
|
_total=len(episodes), _start=min(episodes))
|
||||||
else:
|
else:
|
||||||
# 全季不存在
|
# 全季不存在
|
||||||
__append_no_exists(season, [], len(episodes), min(episodes))
|
__append_no_exists(_season=season, _episodes=[],
|
||||||
|
_total=len(episodes), _start=min(episodes))
|
||||||
# 存在不完整的剧集
|
# 存在不完整的剧集
|
||||||
if no_exists:
|
if no_exists:
|
||||||
logger.info(f"媒体库中已存在部分剧集,缺失:{no_exists}")
|
logger.info(f"媒体库中已存在部分剧集,缺失:{no_exists}")
|
||||||
|
@ -39,6 +39,14 @@ class SearchChain(ChainBase):
|
|||||||
if not indexer_sites:
|
if not indexer_sites:
|
||||||
logger.warn('未开启任何有效站点,无法搜索资源')
|
logger.warn('未开启任何有效站点,无法搜索资源')
|
||||||
return []
|
return []
|
||||||
|
# 补充媒体信息
|
||||||
|
if not mediainfo.names:
|
||||||
|
mediainfo: MediaInfo = self.recognize_media(meta=MetaInfo(title=mediainfo.get_title_string()),
|
||||||
|
mtype=mediainfo.type,
|
||||||
|
tmdbid=mediainfo.tmdb_id)
|
||||||
|
if not mediainfo:
|
||||||
|
logger.error(f'媒体信息识别失败!')
|
||||||
|
return []
|
||||||
# 缺失的媒体信息
|
# 缺失的媒体信息
|
||||||
if no_exists:
|
if no_exists:
|
||||||
# 过滤剧集
|
# 过滤剧集
|
||||||
|
@ -57,6 +57,27 @@ class SubscribeChain(ChainBase):
|
|||||||
return False
|
return False
|
||||||
# 更新媒体图片
|
# 更新媒体图片
|
||||||
self.obtain_image(mediainfo=mediainfo)
|
self.obtain_image(mediainfo=mediainfo)
|
||||||
|
# 总集数
|
||||||
|
if mediainfo.type == MediaType.TV:
|
||||||
|
if not kwargs.get('total_episode'):
|
||||||
|
if not mediainfo.seasons:
|
||||||
|
# 补充媒体信息
|
||||||
|
mediainfo: MediaInfo = self.recognize_media(meta=MetaInfo(title=mediainfo.get_title_string()),
|
||||||
|
mtype=mediainfo.type,
|
||||||
|
tmdbid=mediainfo.tmdb_id)
|
||||||
|
if not mediainfo:
|
||||||
|
logger.error(f"媒体信息识别失败!")
|
||||||
|
return False
|
||||||
|
if not mediainfo.seasons:
|
||||||
|
logger.error(f"媒体信息中没有季集信息,标题:{title},tmdbid:{tmdbid}")
|
||||||
|
return False
|
||||||
|
total_episode = len(mediainfo.seasons.get(kwargs.get('season') or 1) or [])
|
||||||
|
if not total_episode:
|
||||||
|
logger.error(f'未获取到总集数,标题:{title},tmdbid:{tmdbid}')
|
||||||
|
return False
|
||||||
|
kwargs.update({
|
||||||
|
'total_episode': total_episode
|
||||||
|
})
|
||||||
# 添加订阅
|
# 添加订阅
|
||||||
state, err_msg = self.subscribes.add(mediainfo, season=season, **kwargs)
|
state, err_msg = self.subscribes.add(mediainfo, season=season, **kwargs)
|
||||||
if not state:
|
if not state:
|
||||||
|
@ -287,6 +287,7 @@ class UserMessageChain(ChainBase):
|
|||||||
if not medias:
|
if not medias:
|
||||||
self.post_message(title=f"{meta.get_name()} 没有找到对应的媒体信息!", userid=userid)
|
self.post_message(title=f"{meta.get_name()} 没有找到对应的媒体信息!", userid=userid)
|
||||||
return
|
return
|
||||||
|
logger.info(f"搜索到 {len(medias)} 条相关媒体信息")
|
||||||
self._user_cache[userid] = {
|
self._user_cache[userid] = {
|
||||||
'type': action,
|
'type': action,
|
||||||
'items': medias
|
'items': medias
|
||||||
|
@ -31,3 +31,7 @@ class Site(Base):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_by_domain(db: Session, domain: str):
|
def get_by_domain(db: Session, domain: str):
|
||||||
return db.query(Site).filter(Site.domain == domain).first()
|
return db.query(Site).filter(Site.domain == domain).first()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_actives(db: Session):
|
||||||
|
return db.query(Site).filter(Site.is_active is True).all()
|
||||||
|
@ -31,6 +31,12 @@ class Sites:
|
|||||||
"""
|
"""
|
||||||
return Site.list(self._db)
|
return Site.list(self._db)
|
||||||
|
|
||||||
|
def list_active(self):
|
||||||
|
"""
|
||||||
|
按状态获取站点列表
|
||||||
|
"""
|
||||||
|
return Site.get_actives(self._db)
|
||||||
|
|
||||||
def get_by_domain(self, domain: str) -> Site:
|
def get_by_domain(self, domain: str) -> Site:
|
||||||
"""
|
"""
|
||||||
按域名获取站点
|
按域名获取站点
|
||||||
|
@ -5,7 +5,6 @@ from sqlalchemy.orm import Session
|
|||||||
from app.core.context import MediaInfo
|
from app.core.context import MediaInfo
|
||||||
from app.db import SessionLocal
|
from app.db import SessionLocal
|
||||||
from app.db.models.subscribe import Subscribe
|
from app.db.models.subscribe import Subscribe
|
||||||
from app.utils.types import MediaType
|
|
||||||
|
|
||||||
|
|
||||||
class Subscribes:
|
class Subscribes:
|
||||||
@ -21,15 +20,6 @@ class Subscribes:
|
|||||||
"""
|
"""
|
||||||
新增订阅
|
新增订阅
|
||||||
"""
|
"""
|
||||||
# 总集数
|
|
||||||
if mediainfo.type == MediaType.TV:
|
|
||||||
if not kwargs.get('total_episode'):
|
|
||||||
total_episode = len(mediainfo.seasons.get(kwargs.get('season') or 1) or [])
|
|
||||||
if not total_episode:
|
|
||||||
return False, "未识别到总集数"
|
|
||||||
kwargs.update({
|
|
||||||
'total_episode': total_episode
|
|
||||||
})
|
|
||||||
subscribe = Subscribe(name=mediainfo.title,
|
subscribe = Subscribe(name=mediainfo.title,
|
||||||
year=mediainfo.year,
|
year=mediainfo.year,
|
||||||
type=mediainfo.type.value,
|
type=mediainfo.type.value,
|
||||||
|
@ -61,7 +61,7 @@ class TmdbCache(metaclass=Singleton):
|
|||||||
expire = info.get(CACHE_EXPIRE_TIMESTAMP_STR)
|
expire = info.get(CACHE_EXPIRE_TIMESTAMP_STR)
|
||||||
if not expire or int(time.time()) < expire:
|
if not expire or int(time.time()) < expire:
|
||||||
info[CACHE_EXPIRE_TIMESTAMP_STR] = int(time.time()) + EXPIRE_TIMESTAMP
|
info[CACHE_EXPIRE_TIMESTAMP_STR] = int(time.time()) + EXPIRE_TIMESTAMP
|
||||||
self.update(meta, info)
|
self._meta_data[key] = info
|
||||||
elif expire and self._tmdb_cache_expire:
|
elif expire and self._tmdb_cache_expire:
|
||||||
self.delete(key)
|
self.delete(key)
|
||||||
return info or {}
|
return info or {}
|
||||||
@ -136,7 +136,7 @@ class TmdbCache(metaclass=Singleton):
|
|||||||
if cache_year:
|
if cache_year:
|
||||||
cache_year = cache_year[:4]
|
cache_year = cache_year[:4]
|
||||||
self._meta_data[self.__get_key(meta)] = {
|
self._meta_data[self.__get_key(meta)] = {
|
||||||
"id": str(info.get("id")),
|
"id": info.get("id"),
|
||||||
"type": info.get("media_type"),
|
"type": info.get("media_type"),
|
||||||
"year": cache_year,
|
"year": cache_year,
|
||||||
"title": cache_title,
|
"title": cache_title,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user