feat(Plex): 增加从Plex获取图片的URL选项,支持选择返回Plex URL还是TMDB URL

This commit is contained in:
Akimio521
2024-11-02 16:17:25 +08:00
parent b46ede86fc
commit af2075578c

View File

@@ -293,13 +293,18 @@ class Plex:
season_episodes[episode.seasonNumber].append(episode.index)
return videos.key, season_episodes
def get_remote_image_by_id(self, item_id: str, image_type: str, depth: int = 0) -> Optional[str]:
def get_remote_image_by_id(self,
item_id: str,
image_type: str,
depth: int = 0,
plex_url: bool = True) -> Optional[str]:
"""
根据ItemId从Plex查询图片地址
:param item_id: 在Plex中的ID
:param image_type: 图片的类型Poster或者Backdrop等
:param depth: 当前递归深度默认为0
:return: 图片对应在TMDB中的URL
:param plex_url: 是否返回Plex的URL默认为True仅在配置了外网地址和Token时有效
:return: 图片对应在plex服务器或TMDB中的URL
"""
if not self._plex or depth > 2 or not item_id:
return None
@@ -310,7 +315,7 @@ class Plex:
if not item:
return None
# 如果配置了外网播放地址以及Token则默认从Plex媒体服务器获取图片否则返回有外网地址的图片资源
if self._playhost and self._token:
if self._playhost and self._token and plex_url:
query = {"X-Plex-Token": self._token}
if image_type == "Poster":
if item.thumb: