fix rardar
This commit is contained in:
@ -283,7 +283,7 @@ async def arr_movie(apikey: str, mid: int, db: Session = Depends(get_db)) -> Any
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@arr_router.post("/movie", response_model=schemas.Response)
|
@arr_router.post("/movie")
|
||||||
async def arr_add_movie(apikey: str, movie: RadarrMovie) -> Any:
|
async def arr_add_movie(apikey: str, movie: RadarrMovie) -> Any:
|
||||||
"""
|
"""
|
||||||
新增Rardar电影订阅
|
新增Rardar电影订阅
|
||||||
@ -293,11 +293,16 @@ async def arr_add_movie(apikey: str, movie: RadarrMovie) -> Any:
|
|||||||
status_code=403,
|
status_code=403,
|
||||||
detail="认证失败!",
|
detail="认证失败!",
|
||||||
)
|
)
|
||||||
if SubscribeChain().process(title=movie.title,
|
sid = SubscribeChain().process(title=movie.title,
|
||||||
year=str(movie.year) if movie.year else None,
|
year=str(movie.year) if movie.year else None,
|
||||||
mtype=MediaType.MOVIE,
|
mtype=MediaType.MOVIE,
|
||||||
tmdbid=movie.tmdbId):
|
tmdbid=movie.tmdbId)
|
||||||
return {"success": True, "msg": "添加订阅成功!"}
|
if sid:
|
||||||
|
return {
|
||||||
|
"data": {
|
||||||
|
"id": sid
|
||||||
|
}
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=500,
|
status_code=500,
|
||||||
|
@ -34,7 +34,7 @@ class SubscribeChain(ChainBase):
|
|||||||
season: int = None,
|
season: int = None,
|
||||||
userid: str = None,
|
userid: str = None,
|
||||||
username: str = None,
|
username: str = None,
|
||||||
**kwargs) -> bool:
|
**kwargs) -> Optional[int]:
|
||||||
"""
|
"""
|
||||||
识别媒体信息并添加订阅
|
识别媒体信息并添加订阅
|
||||||
"""
|
"""
|
||||||
@ -83,8 +83,8 @@ class SubscribeChain(ChainBase):
|
|||||||
'total_episode': total_episode
|
'total_episode': total_episode
|
||||||
})
|
})
|
||||||
# 添加订阅
|
# 添加订阅
|
||||||
state, err_msg = self.subscribes.add(mediainfo, season=season, **kwargs)
|
sid, err_msg = self.subscribes.add(mediainfo, season=season, **kwargs)
|
||||||
if not state:
|
if not sid:
|
||||||
logger.error(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()} "
|
||||||
@ -99,7 +99,7 @@ class SubscribeChain(ChainBase):
|
|||||||
text=f"评分:{mediainfo.vote_average},来自用户:{username or userid}",
|
text=f"评分:{mediainfo.vote_average},来自用户:{username or userid}",
|
||||||
image=mediainfo.get_message_image())
|
image=mediainfo.get_message_image())
|
||||||
# 返回结果
|
# 返回结果
|
||||||
return state
|
return sid
|
||||||
|
|
||||||
def search(self, sid: int = None, state: str = 'N'):
|
def search(self, sid: int = None, state: str = 'N'):
|
||||||
"""
|
"""
|
||||||
|
@ -16,7 +16,7 @@ class Subscribes:
|
|||||||
def __init__(self, _db=SessionLocal()):
|
def __init__(self, _db=SessionLocal()):
|
||||||
self._db = _db
|
self._db = _db
|
||||||
|
|
||||||
def add(self, mediainfo: MediaInfo, **kwargs) -> Tuple[bool, str]:
|
def add(self, mediainfo: MediaInfo, **kwargs) -> Tuple[int, str]:
|
||||||
"""
|
"""
|
||||||
新增订阅
|
新增订阅
|
||||||
"""
|
"""
|
||||||
@ -29,9 +29,9 @@ class Subscribes:
|
|||||||
**kwargs)
|
**kwargs)
|
||||||
if not subscribe.exists(self._db, tmdbid=mediainfo.tmdb_id, season=kwargs.get('season')):
|
if not subscribe.exists(self._db, tmdbid=mediainfo.tmdb_id, season=kwargs.get('season')):
|
||||||
subscribe.create(self._db)
|
subscribe.create(self._db)
|
||||||
return True, "新增订阅成功"
|
return subscribe.id, "新增订阅成功"
|
||||||
else:
|
else:
|
||||||
return False, "订阅已存在"
|
return subscribe.id, "订阅已存在"
|
||||||
|
|
||||||
def get(self, sid: int) -> Subscribe:
|
def get(self, sid: int) -> Subscribe:
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user