fix webhook image
This commit is contained in:
@ -27,7 +27,7 @@ class FanartModule(_ModuleBase):
|
||||
def init_setting(self) -> Tuple[str, Union[str, bool]]:
|
||||
return "FANART_API_KEY", True
|
||||
|
||||
def obtain_image(self, mediainfo: MediaInfo) -> Optional[MediaInfo]:
|
||||
def obtain_images(self, mediainfo: MediaInfo) -> Optional[MediaInfo]:
|
||||
"""
|
||||
获取图片
|
||||
:param mediainfo: 识别的媒体信息
|
||||
@ -69,7 +69,7 @@ class FanartModule(_ModuleBase):
|
||||
else:
|
||||
image_url = cls._tv_url % queryid
|
||||
try:
|
||||
ret = RequestUtils(proxies=cls._proxies, timeout=5).get_res(image_url)
|
||||
ret = RequestUtils(proxies=cls._proxies, timeout=10).get_res(image_url)
|
||||
if ret:
|
||||
return ret.json()
|
||||
except Exception as err:
|
||||
|
@ -15,7 +15,7 @@ from app.modules.themoviedb.tmdb_cache import TmdbCache
|
||||
from app.utils.dom import DomUtils
|
||||
from app.utils.http import RequestUtils
|
||||
from app.utils.system import SystemUtils
|
||||
from app.schemas.types import MediaType
|
||||
from app.schemas.types import MediaType, MediaImageType
|
||||
|
||||
|
||||
class TheMovieDbModule(_ModuleBase):
|
||||
@ -563,3 +563,37 @@ class TheMovieDbModule(_ModuleBase):
|
||||
定时任务,每10分钟调用一次
|
||||
"""
|
||||
self.cache.save()
|
||||
|
||||
def obtain_specific_image(self, mediaid: Union[str, int], mtype: MediaType,
|
||||
image_type: MediaImageType, image_prefix: str = "w500",
|
||||
season: int = None, episode: int = None) -> Optional[str]:
|
||||
"""
|
||||
获取指定媒体信息图片,返回图片地址
|
||||
:param mediaid: 媒体ID
|
||||
:param mtype: 媒体类型
|
||||
:param image_type: 图片类型
|
||||
:param image_prefix: 图片前缀
|
||||
:param season: 季
|
||||
:param episode: 集
|
||||
"""
|
||||
if not str(mediaid).isdigit():
|
||||
return None
|
||||
# 图片相对路径
|
||||
image_path = None
|
||||
image_prefix = image_prefix or "w500"
|
||||
if not season and not episode:
|
||||
tmdbinfo = self.tmdb.get_info(mtype=mtype, tmdbid=int(mediaid))
|
||||
if tmdbinfo:
|
||||
image_path = tmdbinfo.get(image_type.value)
|
||||
elif season and episode:
|
||||
episodeinfo = self.tmdb.get_tv_episode_detail(tmdbid=int(mediaid), season=season, episode=episode)
|
||||
if episodeinfo:
|
||||
image_path = episodeinfo.get("still_path")
|
||||
elif season:
|
||||
seasoninfo = self.tmdb.get_tv_season_detail(tmdbid=int(mediaid), season=season)
|
||||
if seasoninfo:
|
||||
image_path = seasoninfo.get(image_type.value)
|
||||
|
||||
if image_path:
|
||||
return f"https://image.tmdb.org/t/p/{image_prefix}{image_path}"
|
||||
return None
|
||||
|
Reference in New Issue
Block a user