fix
This commit is contained in:
@ -67,6 +67,20 @@ async def update_subscribe(
|
|||||||
return subscribe
|
return subscribe
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/delete", response_model=schemas.Response)
|
||||||
|
async def delete_subscribe(
|
||||||
|
*,
|
||||||
|
db: Session = Depends(get_db),
|
||||||
|
subscribe_in: schemas.Subscribe,
|
||||||
|
_: User = Depends(get_current_active_superuser),
|
||||||
|
) -> Any:
|
||||||
|
"""
|
||||||
|
删除订阅信息
|
||||||
|
"""
|
||||||
|
Subscribe.delete(db, subscribe_in.id)
|
||||||
|
return {"success": True}
|
||||||
|
|
||||||
|
|
||||||
@router.post("/seerr", response_model=schemas.Response)
|
@router.post("/seerr", response_model=schemas.Response)
|
||||||
async def seerr_subscribe(request: Request, background_tasks: BackgroundTasks,
|
async def seerr_subscribe(request: Request, background_tasks: BackgroundTasks,
|
||||||
authorization: str = Header(None)):
|
authorization: str = Header(None)):
|
||||||
|
@ -199,7 +199,7 @@ class DownloadChain(ChainBase):
|
|||||||
media = context.media_info
|
media = context.media_info
|
||||||
meta = context.meta_info
|
meta = context.meta_info
|
||||||
torrent = context.torrent_info
|
torrent = context.torrent_info
|
||||||
if media.type == MediaType.MOVIE:
|
if media.type != MediaType.TV:
|
||||||
continue
|
continue
|
||||||
item_season = meta.get_season_list()
|
item_season = meta.get_season_list()
|
||||||
if meta.get_episode_list():
|
if meta.get_episode_list():
|
||||||
@ -246,7 +246,7 @@ class DownloadChain(ChainBase):
|
|||||||
for context in contexts:
|
for context in contexts:
|
||||||
media = context.media_info
|
media = context.media_info
|
||||||
meta = context.meta_info
|
meta = context.meta_info
|
||||||
if media.type == MediaType.MOVIE:
|
if media.type != MediaType.TV:
|
||||||
continue
|
continue
|
||||||
if media.tmdb_id == need_tmdbid:
|
if media.tmdb_id == need_tmdbid:
|
||||||
if context in downloaded_list:
|
if context in downloaded_list:
|
||||||
@ -286,7 +286,7 @@ class DownloadChain(ChainBase):
|
|||||||
media = context.media_info
|
media = context.media_info
|
||||||
meta = context.meta_info
|
meta = context.meta_info
|
||||||
torrent = context.torrent_info
|
torrent = context.torrent_info
|
||||||
if media.type == MediaType.MOVIE:
|
if media.type != MediaType.TV:
|
||||||
continue
|
continue
|
||||||
if context in downloaded_list:
|
if context in downloaded_list:
|
||||||
continue
|
continue
|
||||||
|
@ -59,6 +59,8 @@ class SubscribeChain(ChainBase):
|
|||||||
self.obtain_image(mediainfo=mediainfo)
|
self.obtain_image(mediainfo=mediainfo)
|
||||||
# 总集数
|
# 总集数
|
||||||
if mediainfo.type == MediaType.TV:
|
if mediainfo.type == MediaType.TV:
|
||||||
|
if not season:
|
||||||
|
season = 1
|
||||||
if not kwargs.get('total_episode'):
|
if not kwargs.get('total_episode'):
|
||||||
if not mediainfo.seasons:
|
if not mediainfo.seasons:
|
||||||
# 补充媒体信息
|
# 补充媒体信息
|
||||||
@ -71,7 +73,7 @@ class SubscribeChain(ChainBase):
|
|||||||
if not mediainfo.seasons:
|
if not mediainfo.seasons:
|
||||||
logger.error(f"媒体信息中没有季集信息,标题:{title},tmdbid:{tmdbid}")
|
logger.error(f"媒体信息中没有季集信息,标题:{title},tmdbid:{tmdbid}")
|
||||||
return False
|
return False
|
||||||
total_episode = len(mediainfo.seasons.get(kwargs.get('season') or 1) or [])
|
total_episode = len(mediainfo.seasons.get(season) or [])
|
||||||
if not total_episode:
|
if not total_episode:
|
||||||
logger.error(f'未获取到总集数,标题:{title},tmdbid:{tmdbid}')
|
logger.error(f'未获取到总集数,标题:{title},tmdbid:{tmdbid}')
|
||||||
return False
|
return False
|
||||||
@ -81,7 +83,7 @@ class SubscribeChain(ChainBase):
|
|||||||
# 添加订阅
|
# 添加订阅
|
||||||
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:
|
||||||
logger.info(f'{mediainfo.get_title_string()} {err_msg}')
|
logger.error(f'{mediainfo.get_title_string()} {err_msg}')
|
||||||
# 发回原用户
|
# 发回原用户
|
||||||
self.post_message(title=f"{mediainfo.get_title_string()}{metainfo.get_season_string()} "
|
self.post_message(title=f"{mediainfo.get_title_string()}{metainfo.get_season_string()} "
|
||||||
f"添加订阅失败!",
|
f"添加订阅失败!",
|
||||||
@ -89,7 +91,7 @@ class SubscribeChain(ChainBase):
|
|||||||
image=mediainfo.get_message_image(),
|
image=mediainfo.get_message_image(),
|
||||||
userid=userid)
|
userid=userid)
|
||||||
else:
|
else:
|
||||||
logger.error(f'{mediainfo.get_title_string()}{metainfo.get_season_string()} 添加订阅成功')
|
logger.info(f'{mediainfo.get_title_string()}{metainfo.get_season_string()} 添加订阅成功')
|
||||||
# 广而告之
|
# 广而告之
|
||||||
self.post_message(title=f"{mediainfo.get_title_string()}{metainfo.get_season_string()} 已添加订阅",
|
self.post_message(title=f"{mediainfo.get_title_string()}{metainfo.get_season_string()} 已添加订阅",
|
||||||
text=f"评分:{mediainfo.vote_average},来自用户:{username or userid}",
|
text=f"评分:{mediainfo.vote_average},来自用户:{username or userid}",
|
||||||
@ -279,7 +281,7 @@ class SubscribeChain(ChainBase):
|
|||||||
season = season_info.get('season')
|
season = season_info.get('season')
|
||||||
if season == subscribe.season:
|
if season == subscribe.season:
|
||||||
left_episodes = season_info.get('episodes')
|
left_episodes = season_info.get('episodes')
|
||||||
logger.info(f'{mediainfo.get_title_string()} 季 {season} 未下载未完整,'
|
logger.info(f'{mediainfo.get_title_string()} 季 {season} 未下载完整,'
|
||||||
f'更新缺失集数为{len(left_episodes)} ...')
|
f'更新缺失集数为{len(left_episodes)} ...')
|
||||||
self.subscribes.update(subscribe.id, {
|
self.subscribes.update(subscribe.id, {
|
||||||
"lack_episode": len(left_episodes)
|
"lack_episode": len(left_episodes)
|
||||||
|
@ -290,8 +290,6 @@ class UserMessageChain(ChainBase):
|
|||||||
# 合并信息
|
# 合并信息
|
||||||
if mtype:
|
if mtype:
|
||||||
meta.type = mtype
|
meta.type = mtype
|
||||||
elif meta.type != MediaType.TV:
|
|
||||||
meta.type = None
|
|
||||||
if season_num:
|
if season_num:
|
||||||
meta.begin_season = season_num
|
meta.begin_season = season_num
|
||||||
if episode_num:
|
if episode_num:
|
||||||
|
@ -18,7 +18,7 @@ class MetaBase(object):
|
|||||||
# 副标题
|
# 副标题
|
||||||
subtitle: Optional[str] = None
|
subtitle: Optional[str] = None
|
||||||
# 类型 电影、电视剧
|
# 类型 电影、电视剧
|
||||||
type: Optional[MediaType] = None
|
type: MediaType = MediaType.UNKNOWN
|
||||||
# 识别的中文名
|
# 识别的中文名
|
||||||
cn_name: Optional[str] = None
|
cn_name: Optional[str] = None
|
||||||
# 识别的英文名
|
# 识别的英文名
|
||||||
@ -231,10 +231,10 @@ class MetaBase(object):
|
|||||||
(str(self.begin_season).rjust(2, "0"),
|
(str(self.begin_season).rjust(2, "0"),
|
||||||
str(self.end_season).rjust(2, "0"))
|
str(self.end_season).rjust(2, "0"))
|
||||||
else:
|
else:
|
||||||
if self.type == MediaType.MOVIE:
|
if self.type == MediaType.TV:
|
||||||
return ""
|
|
||||||
else:
|
|
||||||
return "S01"
|
return "S01"
|
||||||
|
else:
|
||||||
|
return ""
|
||||||
|
|
||||||
def get_season(self) -> str:
|
def get_season(self) -> str:
|
||||||
"""
|
"""
|
||||||
@ -243,7 +243,7 @@ class MetaBase(object):
|
|||||||
if self.begin_season is not None:
|
if self.begin_season is not None:
|
||||||
return self.get_season_string()
|
return self.get_season_string()
|
||||||
else:
|
else:
|
||||||
return "S01"
|
return ""
|
||||||
|
|
||||||
def get_begin_season_string(self) -> str:
|
def get_begin_season_string(self) -> str:
|
||||||
"""
|
"""
|
||||||
@ -252,10 +252,10 @@ class MetaBase(object):
|
|||||||
if self.begin_season is not None:
|
if self.begin_season is not None:
|
||||||
return "S%s" % str(self.begin_season).rjust(2, "0")
|
return "S%s" % str(self.begin_season).rjust(2, "0")
|
||||||
else:
|
else:
|
||||||
if self.type == MediaType.MOVIE:
|
if self.type == MediaType.TV:
|
||||||
return ""
|
|
||||||
else:
|
|
||||||
return "S01"
|
return "S01"
|
||||||
|
else:
|
||||||
|
return ""
|
||||||
|
|
||||||
def get_season_seq(self) -> str:
|
def get_season_seq(self) -> str:
|
||||||
"""
|
"""
|
||||||
@ -264,20 +264,20 @@ class MetaBase(object):
|
|||||||
if self.begin_season is not None:
|
if self.begin_season is not None:
|
||||||
return str(self.begin_season)
|
return str(self.begin_season)
|
||||||
else:
|
else:
|
||||||
if self.type == MediaType.MOVIE:
|
if self.type == MediaType.TV:
|
||||||
return ""
|
|
||||||
else:
|
|
||||||
return "1"
|
return "1"
|
||||||
|
else:
|
||||||
|
return ""
|
||||||
|
|
||||||
def get_season_list(self) -> List[int]:
|
def get_season_list(self) -> List[int]:
|
||||||
"""
|
"""
|
||||||
返回季的数组
|
返回季的数组
|
||||||
"""
|
"""
|
||||||
if self.begin_season is None:
|
if self.begin_season is None:
|
||||||
if self.type == MediaType.MOVIE:
|
if self.type == MediaType.TV:
|
||||||
return []
|
|
||||||
else:
|
|
||||||
return [1]
|
return [1]
|
||||||
|
else:
|
||||||
|
return []
|
||||||
elif self.end_season is not None:
|
elif self.end_season is not None:
|
||||||
return [season for season in range(self.begin_season, self.end_season + 1)]
|
return [season for season in range(self.begin_season, self.end_season + 1)]
|
||||||
else:
|
else:
|
||||||
@ -377,9 +377,7 @@ class MetaBase(object):
|
|||||||
"""
|
"""
|
||||||
返回季集字符串
|
返回季集字符串
|
||||||
"""
|
"""
|
||||||
if self.type == MediaType.MOVIE:
|
if self.type == MediaType.TV:
|
||||||
return ""
|
|
||||||
else:
|
|
||||||
seaion = self.get_season_string()
|
seaion = self.get_season_string()
|
||||||
episode = self.get_episode_string()
|
episode = self.get_episode_string()
|
||||||
if seaion and episode:
|
if seaion and episode:
|
||||||
@ -388,6 +386,8 @@ class MetaBase(object):
|
|||||||
return "%s" % seaion
|
return "%s" % seaion
|
||||||
elif episode:
|
elif episode:
|
||||||
return "%s" % episode
|
return "%s" % episode
|
||||||
|
else:
|
||||||
|
return ""
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def get_resource_type_string(self) -> str:
|
def get_resource_type_string(self) -> str:
|
||||||
|
@ -122,9 +122,6 @@ class MetaVideo(MetaBase):
|
|||||||
self.init_subtitle(self.org_string)
|
self.init_subtitle(self.org_string)
|
||||||
if not self._subtitle_flag and self.subtitle:
|
if not self._subtitle_flag and self.subtitle:
|
||||||
self.init_subtitle(self.subtitle)
|
self.init_subtitle(self.subtitle)
|
||||||
# 没有识别出类型时默认为电影
|
|
||||||
if not self.type:
|
|
||||||
self.type = MediaType.MOVIE
|
|
||||||
# 去掉名字中不需要的干扰字符,过短的纯数字不要
|
# 去掉名字中不需要的干扰字符,过短的纯数字不要
|
||||||
self.cn_name = self.__fix_name(self.cn_name)
|
self.cn_name = self.__fix_name(self.cn_name)
|
||||||
self.en_name = StringUtils.str_title(self.__fix_name(self.en_name))
|
self.en_name = StringUtils.str_title(self.__fix_name(self.en_name))
|
||||||
|
@ -207,7 +207,7 @@ class TorrentHelper:
|
|||||||
# 控重的主链是名称、年份、季、集
|
# 控重的主链是名称、年份、季、集
|
||||||
meta = context.meta_info
|
meta = context.meta_info
|
||||||
media = context.media_info
|
media = context.media_info
|
||||||
if media.type != MediaType.MOVIE:
|
if media.type == MediaType.TV:
|
||||||
media_name = "%s%s" % (media.get_title_string(),
|
media_name = "%s%s" % (media.get_title_string(),
|
||||||
meta.get_season_episode_string())
|
meta.get_season_episode_string())
|
||||||
else:
|
else:
|
||||||
|
@ -63,7 +63,7 @@ class FanartModule(_ModuleBase):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@lru_cache(maxsize=256)
|
@lru_cache(maxsize=256)
|
||||||
def __request_fanart(cls, media_type: MediaType, queryid: str) -> Optional[dict]:
|
def __request_fanart(cls, media_type: MediaType, queryid: Union[str, int]) -> Optional[dict]:
|
||||||
if media_type == MediaType.MOVIE:
|
if media_type == MediaType.MOVIE:
|
||||||
image_url = cls._movie_url % queryid
|
image_url = cls._movie_url % queryid
|
||||||
else:
|
else:
|
||||||
|
@ -344,8 +344,8 @@ class FileTransferModule(_ModuleBase):
|
|||||||
target_dir = target_dir / meidainfo.type.value / meidainfo.category
|
target_dir = target_dir / meidainfo.type.value / meidainfo.category
|
||||||
|
|
||||||
# 重命名格式
|
# 重命名格式
|
||||||
rename_format = settings.MOVIE_RENAME_FORMAT \
|
rename_format = settings.TV_RENAME_FORMAT \
|
||||||
if meidainfo.type == MediaType.MOVIE else settings.TV_RENAME_FORMAT
|
if meidainfo.type == MediaType.TV else settings.MOVIE_RENAME_FORMAT
|
||||||
|
|
||||||
# 判断是否为蓝光原盘
|
# 判断是否为蓝光原盘
|
||||||
bluray_flag = self.__is_bluray_dir(in_path)
|
bluray_flag = self.__is_bluray_dir(in_path)
|
||||||
|
@ -167,10 +167,10 @@ class TorrentSpider:
|
|||||||
})
|
})
|
||||||
# 分类条件
|
# 分类条件
|
||||||
if self.category:
|
if self.category:
|
||||||
if self.mtype == MediaType.MOVIE:
|
if self.mtype == MediaType.TV:
|
||||||
cats = self.category.get("movie") or []
|
|
||||||
elif self.mtype:
|
|
||||||
cats = self.category.get("tv") or []
|
cats = self.category.get("tv") or []
|
||||||
|
elif self.mtype == MediaType.MOVIE:
|
||||||
|
cats = self.category.get("movie") or []
|
||||||
else:
|
else:
|
||||||
cats = (self.category.get("movie") or []) + (self.category.get("tv") or [])
|
cats = (self.category.get("movie") or []) + (self.category.get("tv") or [])
|
||||||
for cat in cats:
|
for cat in cats:
|
||||||
|
@ -61,7 +61,7 @@ class TheMovieDbModule(_ModuleBase):
|
|||||||
info = self.tmdb.get_info(mtype=mtype, tmdbid=tmdbid)
|
info = self.tmdb.get_info(mtype=mtype, tmdbid=tmdbid)
|
||||||
else:
|
else:
|
||||||
logger.info(f"正在识别 {meta.get_name()} ...")
|
logger.info(f"正在识别 {meta.get_name()} ...")
|
||||||
if meta.type != MediaType.TV and not meta.year:
|
if meta.type == MediaType.UNKNOWN and not meta.year:
|
||||||
info = self.tmdb.match_multi(meta.get_name())
|
info = self.tmdb.match_multi(meta.get_name())
|
||||||
else:
|
else:
|
||||||
if meta.type == MediaType.TV:
|
if meta.type == MediaType.TV:
|
||||||
@ -111,10 +111,10 @@ class TheMovieDbModule(_ModuleBase):
|
|||||||
|
|
||||||
if info:
|
if info:
|
||||||
# 确定二级分类
|
# 确定二级分类
|
||||||
if info.get('media_type') == MediaType.MOVIE:
|
if info.get('media_type') == MediaType.TV:
|
||||||
cat = self.category.get_movie_category(info)
|
|
||||||
else:
|
|
||||||
cat = self.category.get_tv_category(info)
|
cat = self.category.get_tv_category(info)
|
||||||
|
else:
|
||||||
|
cat = self.category.get_movie_category(info)
|
||||||
# 赋值TMDB信息并返回
|
# 赋值TMDB信息并返回
|
||||||
mediainfo = MediaInfo(tmdb_info=info)
|
mediainfo = MediaInfo(tmdb_info=info)
|
||||||
mediainfo.set_category(cat)
|
mediainfo.set_category(cat)
|
||||||
@ -139,10 +139,10 @@ class TheMovieDbModule(_ModuleBase):
|
|||||||
|
|
||||||
if not meta.get_name():
|
if not meta.get_name():
|
||||||
return []
|
return []
|
||||||
if not meta.type and not meta.year:
|
if meta.type == MediaType.UNKNOWN and not meta.year:
|
||||||
results = self.tmdb.search_multiis(meta.get_name())
|
results = self.tmdb.search_multiis(meta.get_name())
|
||||||
else:
|
else:
|
||||||
if not meta.type:
|
if meta.type == MediaType.UNKNOWN:
|
||||||
results = list(
|
results = list(
|
||||||
set(self.tmdb.search_movies(meta.get_name(), meta.year))
|
set(self.tmdb.search_movies(meta.get_name(), meta.year))
|
||||||
.union(set(self.tmdb.search_tv_tmdbinfos(meta.get_name(), meta.year)))
|
.union(set(self.tmdb.search_tv_tmdbinfos(meta.get_name(), meta.year)))
|
||||||
|
Reference in New Issue
Block a user