- 修复Plex媒体图片展示与跳转
This commit is contained in:
parent
2af7abee3c
commit
9b97e478aa
@ -60,7 +60,7 @@ class Plex(metaclass=Singleton):
|
|||||||
logger.error(f"Plex服务器连接失败:{str(e)}")
|
logger.error(f"Plex服务器连接失败:{str(e)}")
|
||||||
|
|
||||||
@lru_cache(maxsize=10)
|
@lru_cache(maxsize=10)
|
||||||
def __get_library_images(self, library_key: str) -> Optional[List[str]]:
|
def __get_library_images(self, library_key: str, mtype: int) -> Optional[List[str]]:
|
||||||
"""
|
"""
|
||||||
获取媒体服务器最近添加的媒体的图片列表
|
获取媒体服务器最近添加的媒体的图片列表
|
||||||
param: library_key
|
param: library_key
|
||||||
@ -76,7 +76,7 @@ class Plex(metaclass=Singleton):
|
|||||||
total_size = 4
|
total_size = 4
|
||||||
# 如果总数不足,接续获取下一页
|
# 如果总数不足,接续获取下一页
|
||||||
while len(poster_urls) < total_size:
|
while len(poster_urls) < total_size:
|
||||||
items = self._plex.fetchItems(f"/hubs/home/recentlyAdded?type={type}§ionID={library_key}",
|
items = self._plex.fetchItems(f"/hubs/home/recentlyAdded?type={mtype}§ionID={library_key}",
|
||||||
container_size=total_size,
|
container_size=total_size,
|
||||||
container_start=container_start)
|
container_start=container_start)
|
||||||
for item in items:
|
for item in items:
|
||||||
@ -115,11 +115,12 @@ class Plex(metaclass=Singleton):
|
|||||||
match library.type:
|
match library.type:
|
||||||
case "movie":
|
case "movie":
|
||||||
library_type = MediaType.MOVIE.value
|
library_type = MediaType.MOVIE.value
|
||||||
|
image_list = self.__get_library_images(library.key, 1)
|
||||||
case "show":
|
case "show":
|
||||||
library_type = MediaType.TV.value
|
library_type = MediaType.TV.value
|
||||||
|
image_list = self.__get_library_images(library.key, 2)
|
||||||
case _:
|
case _:
|
||||||
continue
|
continue
|
||||||
image_list = self.__get_library_images(library.key)
|
|
||||||
libraries.append(
|
libraries.append(
|
||||||
schemas.MediaServerLibrary(
|
schemas.MediaServerLibrary(
|
||||||
id=library.key,
|
id=library.key,
|
||||||
@ -602,7 +603,7 @@ class Plex(metaclass=Singleton):
|
|||||||
拼装媒体播放链接
|
拼装媒体播放链接
|
||||||
:param item_id: 媒体的的ID
|
:param item_id: 媒体的的ID
|
||||||
"""
|
"""
|
||||||
return f'{self._playhost or self._host}#!/server/{self._plex.machineIdentifier}/details?key={item_id}'
|
return f'{self._playhost or self._host}web/index.html#!/server/{self._plex.machineIdentifier}/details?key={item_id}'
|
||||||
|
|
||||||
def get_resume(self, num: int = 12) -> Optional[List[schemas.MediaServerPlayItem]]:
|
def get_resume(self, num: int = 12) -> Optional[List[schemas.MediaServerPlayItem]]:
|
||||||
"""
|
"""
|
||||||
@ -631,7 +632,7 @@ class Plex(metaclass=Singleton):
|
|||||||
link=link,
|
link=link,
|
||||||
percent=item.viewOffset / item.duration * 100 if item.viewOffset and item.duration else 0
|
percent=item.viewOffset / item.duration * 100 if item.viewOffset and item.duration else 0
|
||||||
))
|
))
|
||||||
return ret_resume
|
return ret_resume[:num]
|
||||||
|
|
||||||
def get_latest(self, num: int = 20) -> Optional[List[schemas.MediaServerPlayItem]]:
|
def get_latest(self, num: int = 20) -> Optional[List[schemas.MediaServerPlayItem]]:
|
||||||
"""
|
"""
|
||||||
@ -655,4 +656,4 @@ class Plex(metaclass=Singleton):
|
|||||||
image=image,
|
image=image,
|
||||||
link=link
|
link=link
|
||||||
))
|
))
|
||||||
return ret_resume
|
return ret_resume[:num]
|
||||||
|
@ -1 +1 @@
|
|||||||
APP_VERSION = 'v1.5.7-1'
|
APP_VERSION = 'v1.5.7-2'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user