Merge pull request #3102 from InfinityPacer/feature/module

This commit is contained in:
jxxghp
2024-11-15 12:01:21 +08:00
committed by GitHub

View File

@@ -162,26 +162,26 @@ class Plex:
def get_medias_count(self) -> schemas.Statistic: def get_medias_count(self) -> schemas.Statistic:
""" """
获得电影、电视剧、动漫媒体数量 获得电影、电视剧、动漫媒体数量
:return: MovieCount SeriesCount SongCount :return: movie_count tv_count episode_count
""" """
if not self._plex: if not self._plex:
return schemas.Statistic() return schemas.Statistic()
sections = self._plex.library.sections() sections = self._plex.library.sections()
MovieCount = SeriesCount = EpisodeCount = 0 movie_count = tv_count = episode_count = 0
# 媒体库白名单 # 媒体库白名单
allow_library = [lib.id for lib in self.get_librarys(hidden=True)] allow_library = [lib.id for lib in self.get_librarys(hidden=True)]
for sec in sections: for sec in sections:
if str(sec.key) not in allow_library: if sec.key not in allow_library:
continue continue
if sec.type == "movie": if sec.type == "movie":
MovieCount += sec.totalSize movie_count += sec.totalSize
if sec.type == "show": if sec.type == "show":
SeriesCount += sec.totalSize tv_count += sec.totalSize
EpisodeCount += sec.totalViewSize(libtype='episode') episode_count += sec.totalViewSize(libtype="episode")
return schemas.Statistic( return schemas.Statistic(
movie_count=MovieCount, movie_count=movie_count,
tv_count=SeriesCount, tv_count=tv_count,
episode_count=EpisodeCount episode_count=episode_count
) )
def get_movies(self, def get_movies(self,
@@ -721,7 +721,7 @@ class Plex:
if not self._plex: if not self._plex:
return [] return []
# 媒体库白名单 # 媒体库白名单
allow_library = ",".join([lib.id for lib in self.get_librarys(hidden=True)]) allow_library = ",".join(map(str, (lib.id for lib in self.get_librarys(hidden=True))))
params = {"contentDirectoryID": allow_library} params = {"contentDirectoryID": allow_library}
items = self._plex.fetchItems("/hubs/continueWatching/items", items = self._plex.fetchItems("/hubs/continueWatching/items",
container_start=0, container_start=0,
@@ -757,7 +757,7 @@ class Plex:
if not self._plex: if not self._plex:
return None return None
# 请求参数(除黑名单) # 请求参数(除黑名单)
allow_library = ",".join([lib.id for lib in self.get_librarys(hidden=True)]) allow_library = ",".join(map(str, (lib.id for lib in self.get_librarys(hidden=True))))
params = { params = {
"contentDirectoryID": allow_library, "contentDirectoryID": allow_library,
"count": num, "count": num,