mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-19 14:04:17 +08:00
fix(dashboard): distinguish empty media results (#6187)
This commit is contained in:
@@ -293,23 +293,23 @@ class PlexModule(_ModuleBase, _MediaServerBase[Plex]):
|
||||
) for season, episodes in seasoninfo.items()]
|
||||
|
||||
def mediaserver_playing(self, server: str, count: Optional[int] = 20,
|
||||
**kwargs) -> List[schemas.MediaServerPlayItem]:
|
||||
**kwargs) -> Optional[List[schemas.MediaServerPlayItem]]:
|
||||
"""
|
||||
获取媒体服务器正在播放信息
|
||||
"""
|
||||
server_obj: Plex = self.get_instance(server)
|
||||
if not server_obj:
|
||||
return []
|
||||
return None
|
||||
return server_obj.get_resume(num=count)
|
||||
|
||||
def mediaserver_latest(self, server: Optional[str] = None, count: Optional[int] = 20,
|
||||
**kwargs) -> List[schemas.MediaServerPlayItem]:
|
||||
**kwargs) -> Optional[List[schemas.MediaServerPlayItem]]:
|
||||
"""
|
||||
获取媒体服务器最新入库条目
|
||||
"""
|
||||
server_obj: Plex = self.get_instance(server)
|
||||
if not server_obj:
|
||||
return []
|
||||
return None
|
||||
return server_obj.get_latest(num=count)
|
||||
|
||||
def mediaserver_latest_images(self,
|
||||
@@ -331,8 +331,7 @@ class PlexModule(_ModuleBase, _MediaServerBase[Plex]):
|
||||
return []
|
||||
|
||||
links = []
|
||||
items: List[schemas.MediaServerPlayItem] = self.mediaserver_latest(server=server, count=count,
|
||||
username=username)
|
||||
items = self.mediaserver_latest(server=server, count=count, username=username) or []
|
||||
for item in items:
|
||||
link = server_obj.get_remote_image_by_id(item_id=item.id,
|
||||
image_type="Backdrop",
|
||||
|
||||
@@ -122,17 +122,17 @@ class Plex:
|
||||
return [f"{self._host.rstrip('/') + url}?X-Plex-Token={self._token}" for url in
|
||||
list(poster_urls.keys())[:total_size]]
|
||||
|
||||
def get_librarys(self, hidden: Optional[bool] = False) -> List[schemas.MediaServerLibrary]:
|
||||
def get_librarys(self, hidden: Optional[bool] = False) -> Optional[List[schemas.MediaServerLibrary]]:
|
||||
"""
|
||||
获取媒体服务器所有媒体库列表
|
||||
"""
|
||||
if not self._plex:
|
||||
return []
|
||||
return None
|
||||
try:
|
||||
self._libraries = self._plex.library.sections()
|
||||
except Exception as err:
|
||||
logger.error(f"获取媒体服务器所有媒体库列表出错:{str(err)}")
|
||||
return []
|
||||
return None
|
||||
libraries = []
|
||||
for library in self._libraries:
|
||||
if hidden and self._sync_libraries and "all" not in self._sync_libraries \
|
||||
@@ -171,7 +171,7 @@ class Plex:
|
||||
sections = self._plex.library.sections()
|
||||
movie_count = tv_count = episode_count = 0
|
||||
# 媒体库白名单
|
||||
allow_library = [str(lib.id) for lib in self.get_librarys(hidden=True)]
|
||||
allow_library = [str(lib.id) for lib in self.get_librarys(hidden=True) or []]
|
||||
for sec in sections:
|
||||
if str(sec.key) not in allow_library:
|
||||
continue
|
||||
@@ -832,9 +832,12 @@ class Plex:
|
||||
获取继续观看的媒体
|
||||
"""
|
||||
if not self._plex:
|
||||
return []
|
||||
return None
|
||||
# 媒体库白名单
|
||||
allow_library = ",".join(map(str, (lib.id for lib in self.get_librarys(hidden=True))))
|
||||
libraries = self.get_librarys(hidden=True)
|
||||
if libraries is None:
|
||||
return None
|
||||
allow_library = ",".join(map(str, (lib.id for lib in libraries)))
|
||||
params = {"contentDirectoryID": allow_library}
|
||||
items = self._plex.fetchItems("/hubs/continueWatching/items",
|
||||
container_start=0,
|
||||
@@ -871,7 +874,10 @@ class Plex:
|
||||
if not self._plex:
|
||||
return None
|
||||
# 请求参数(除黑名单)
|
||||
allow_library = ",".join(map(str, (lib.id for lib in self.get_librarys(hidden=True))))
|
||||
libraries = self.get_librarys(hidden=True)
|
||||
if libraries is None:
|
||||
return None
|
||||
allow_library = ",".join(map(str, (lib.id for lib in libraries)))
|
||||
params = {
|
||||
"contentDirectoryID": allow_library,
|
||||
"count": num,
|
||||
|
||||
Reference in New Issue
Block a user