fix
This commit is contained in:
parent
f7e395c834
commit
e1f19b2ce0
@ -4,6 +4,7 @@ from fastapi import APIRouter, HTTPException, Depends, Request
|
|||||||
from requests import Session
|
from requests import Session
|
||||||
|
|
||||||
from app import schemas
|
from app import schemas
|
||||||
|
from app.chain.identify import IdentifyChain
|
||||||
from app.chain.subscribe import SubscribeChain
|
from app.chain.subscribe import SubscribeChain
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.db import get_db
|
from app.db import get_db
|
||||||
@ -468,21 +469,27 @@ async def arr_series_lookup(apikey: str, term: str, db: Session = Depends(get_db
|
|||||||
status_code=403,
|
status_code=403,
|
||||||
detail="认证失败!",
|
detail="认证失败!",
|
||||||
)
|
)
|
||||||
|
# 季列表
|
||||||
|
seasons = []
|
||||||
if not term.startswith("tvdb:"):
|
if not term.startswith("tvdb:"):
|
||||||
title = term
|
title = term
|
||||||
subscribe = Subscribe.get_by_title(db, title)
|
subscribe = Subscribe.get_by_title(db, title)
|
||||||
else:
|
else:
|
||||||
tmdbid = term.replace("tvdb:", "")
|
tmdbid = term.replace("tvdb:", "")
|
||||||
subscribe = Subscribe.get_by_tmdbid(db, int(tmdbid))
|
subscribe = Subscribe.get_by_tmdbid(db, int(tmdbid))
|
||||||
|
if not subscribe:
|
||||||
|
# 查询TMDB季信息
|
||||||
|
tmdbinfo = IdentifyChain().tvdb_info(tvdbid=int(tmdbid))
|
||||||
|
if tmdbinfo:
|
||||||
|
season_num = tmdbinfo.get('season')
|
||||||
|
if season_num:
|
||||||
|
seasons = list(range(1, season_num + 1))
|
||||||
if subscribe:
|
if subscribe:
|
||||||
return [SonarrSeries(
|
return [SonarrSeries(
|
||||||
id=subscribe.id,
|
id=subscribe.id,
|
||||||
title=subscribe.name,
|
title=subscribe.name,
|
||||||
seasonCount=1,
|
seasonCount=1,
|
||||||
seasons=[{
|
seasons=[subscribe.season],
|
||||||
"seasonNumber": subscribe.season,
|
|
||||||
"monitored": True,
|
|
||||||
}],
|
|
||||||
year=subscribe.year,
|
year=subscribe.year,
|
||||||
isAvailable=True,
|
isAvailable=True,
|
||||||
monitored=True,
|
monitored=True,
|
||||||
@ -493,7 +500,7 @@ async def arr_series_lookup(apikey: str, term: str, db: Session = Depends(get_db
|
|||||||
hasFile=False,
|
hasFile=False,
|
||||||
)]
|
)]
|
||||||
else:
|
else:
|
||||||
return [SonarrSeries()]
|
return [SonarrSeries(seasons=seasons)]
|
||||||
|
|
||||||
|
|
||||||
@arr_router.get("/series/{tid}")
|
@arr_router.get("/series/{tid}")
|
||||||
@ -534,7 +541,7 @@ async def arr_serie(apikey: str, tid: int, db: Session = Depends(get_db)) -> Any
|
|||||||
|
|
||||||
|
|
||||||
@arr_router.post("/series")
|
@arr_router.post("/series")
|
||||||
async def arr_add_series(request: Request, apikey: str) -> Any:
|
async def arr_add_series(request: Request, apikey: str, tv: schemas.SonarrSeries) -> Any:
|
||||||
"""
|
"""
|
||||||
新增Sonarr剧集订阅
|
新增Sonarr剧集订阅
|
||||||
"""
|
"""
|
||||||
@ -544,7 +551,6 @@ async def arr_add_series(request: Request, apikey: str) -> Any:
|
|||||||
detail="认证失败!",
|
detail="认证失败!",
|
||||||
)
|
)
|
||||||
logger.info(await request.body())
|
logger.info(await request.body())
|
||||||
'''
|
|
||||||
sid = 0
|
sid = 0
|
||||||
for season in tv.seasons:
|
for season in tv.seasons:
|
||||||
sid = SubscribeChain().process(title=tv.title,
|
sid = SubscribeChain().process(title=tv.title,
|
||||||
@ -562,7 +568,6 @@ async def arr_add_series(request: Request, apikey: str) -> Any:
|
|||||||
status_code=500,
|
status_code=500,
|
||||||
detail="添加订阅失败!"
|
detail="添加订阅失败!"
|
||||||
)
|
)
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
@arr_router.delete("/series/{tid}")
|
@arr_router.delete("/series/{tid}")
|
||||||
|
@ -80,6 +80,9 @@ class ChainBase(AbstractSingleton, metaclass=Singleton):
|
|||||||
def douban_info(self, doubanid: str) -> Optional[dict]:
|
def douban_info(self, doubanid: str) -> Optional[dict]:
|
||||||
return self.run_module("douban_info", doubanid=doubanid)
|
return self.run_module("douban_info", doubanid=doubanid)
|
||||||
|
|
||||||
|
def tvdb_info(self, tvdbid: int) -> Optional[dict]:
|
||||||
|
return self.run_module("tvdb_info", tvdbid=tvdbid)
|
||||||
|
|
||||||
def message_parser(self, body: Any, form: Any, args: Any) -> Optional[dict]:
|
def message_parser(self, body: Any, form: Any, args: Any) -> Optional[dict]:
|
||||||
return self.run_module("message_parser", body=body, form=form, args=args)
|
return self.run_module("message_parser", body=body, form=form, args=args)
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ class Settings(BaseSettings):
|
|||||||
TMDB_API_DOMAIN: str = "api.themoviedb.org"
|
TMDB_API_DOMAIN: str = "api.themoviedb.org"
|
||||||
# TMDB API Key
|
# TMDB API Key
|
||||||
TMDB_API_KEY: str = "db55323b8d3e4154498498a75642b381"
|
TMDB_API_KEY: str = "db55323b8d3e4154498498a75642b381"
|
||||||
|
# TVDB API Key
|
||||||
|
TVDB_API_KEY: str = "6b481081-10aa-440c-99f2-21d17717ee02"
|
||||||
# Fanart API Key
|
# Fanart API Key
|
||||||
FANART_API_KEY: str = "d2d31f9ecabea050fc7d68aa3146015f"
|
FANART_API_KEY: str = "d2d31f9ecabea050fc7d68aa3146015f"
|
||||||
# 支持的后缀格式
|
# 支持的后缀格式
|
||||||
|
@ -68,6 +68,14 @@ class _ModuleBase(metaclass=ABCMeta):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def tvdb_info(self, tvdbid: int) -> Optional[dict]:
|
||||||
|
"""
|
||||||
|
获取TVDB信息
|
||||||
|
:param tvdbid: int
|
||||||
|
:return: 识别的媒体信息,包括剧集信息
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def message_parser(self, body: Any, form: Any, args: Any) -> Optional[dict]:
|
def message_parser(self, body: Any, form: Any, args: Any) -> Optional[dict]:
|
||||||
"""
|
"""
|
||||||
解析消息内容,返回字典,注意以下约定值:
|
解析消息内容,返回字典,注意以下约定值:
|
||||||
|
@ -37,6 +37,7 @@ class DoubanModule(_ModuleBase):
|
|||||||
"""
|
"""
|
||||||
if not doubanid:
|
if not doubanid:
|
||||||
return None
|
return None
|
||||||
|
logger.info(f"开始获取豆瓣信息:{doubanid} ...")
|
||||||
douban_info = self.doubanapi.movie_detail(doubanid)
|
douban_info = self.doubanapi.movie_detail(doubanid)
|
||||||
if douban_info:
|
if douban_info:
|
||||||
celebrities = self.doubanapi.movie_celebrities(doubanid)
|
celebrities = self.doubanapi.movie_celebrities(doubanid)
|
||||||
|
33
app/modules/thetvdb/__init__.py
Normal file
33
app/modules/thetvdb/__init__.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from typing import Optional, Tuple, Union
|
||||||
|
|
||||||
|
import tvdb_api
|
||||||
|
|
||||||
|
from app.core.config import settings
|
||||||
|
from app.log import logger
|
||||||
|
from app.modules import _ModuleBase
|
||||||
|
|
||||||
|
|
||||||
|
class TheTvDbModule(_ModuleBase):
|
||||||
|
|
||||||
|
tvdb: tvdb_api.Tvdb = None
|
||||||
|
|
||||||
|
def init_module(self) -> None:
|
||||||
|
self.tvdb = tvdb_api.Tvdb(apikey=settings.TVDB_API_KEY)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def init_setting(self) -> Tuple[str, Union[str, bool]]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tvdb_info(self, tvdbid: int) -> Optional[dict]:
|
||||||
|
"""
|
||||||
|
获取TVDB信息
|
||||||
|
:param tvdbid: int
|
||||||
|
:return: 识别的媒体信息,包括剧集信息
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
logger.info(f"开始获取TVDB信息: {tvdbid} ...")
|
||||||
|
return self.tvdb[tvdbid].data
|
||||||
|
except Exception as err:
|
||||||
|
logger.error(f"获取TVDB信息失败: {err}")
|
@ -42,3 +42,4 @@ chardet~=4.0.0
|
|||||||
starlette~=0.27.0
|
starlette~=0.27.0
|
||||||
PyVirtualDisplay~=3.0
|
PyVirtualDisplay~=3.0
|
||||||
Cython~=0.29.35
|
Cython~=0.29.35
|
||||||
|
tvdb_api~=3.1
|
Loading…
x
Reference in New Issue
Block a user