From 02acc8bc350c3ab90804c6b8117cc9120737e620 Mon Sep 17 00:00:00 2001 From: zhu0823 Date: Tue, 16 Apr 2024 16:38:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20plex=E7=BB=A7=E7=BB=AD=E8=A7=82?= =?UTF-8?q?=E7=9C=8B=E8=BF=87=E6=BB=A4=E9=BB=91=E5=90=8D=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/modules/plex/plex.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/modules/plex/plex.py b/app/modules/plex/plex.py index 8e5f7aae..34aacec2 100644 --- a/app/modules/plex/plex.py +++ b/app/modules/plex/plex.py @@ -4,7 +4,7 @@ from pathlib import Path from typing import List, Optional, Dict, Tuple, Generator, Any from urllib.parse import quote_plus -from plexapi import media +from plexapi import media, utils from plexapi.server import PlexServer from app import schemas @@ -610,7 +610,11 @@ class Plex: """ if not self._plex: return [] - items = self._plex.fetchItems('/hubs/continueWatching/items', container_start=0, container_size=num) + # 过滤黑名单 + allow_library = ",".join([lib.id for lib in self.get_librarys()]) + query = {'contentDirectoryID': allow_library} + path = '/hubs/continueWatching/items' + utils.joinArgs(query) + items = self._plex.fetchItems(path, container_start=0, container_size=num) ret_resume = [] for item in items: item_type = MediaType.MOVIE.value if item.TYPE == "movie" else MediaType.TV.value From c98c8c8836dc85f7bd6da645089c9e296bdcac30 Mon Sep 17 00:00:00 2001 From: zhu0823 Date: Tue, 16 Apr 2024 17:42:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20plex=E5=AA=92=E4=BD=93=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1=E8=BF=87=E6=BB=A4=E9=BB=91=E5=90=8D?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/modules/plex/plex.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/modules/plex/plex.py b/app/modules/plex/plex.py index 34aacec2..73ce7a37 100644 --- a/app/modules/plex/plex.py +++ b/app/modules/plex/plex.py @@ -142,7 +142,11 @@ class Plex: return schemas.Statistic() sections = self._plex.library.sections() MovieCount = SeriesCount = EpisodeCount = 0 + # 媒体库白名单 + allow_library = [lib.id for lib in self.get_librarys()] for sec in sections: + if str(sec.key) not in allow_library: + continue if sec.type == "movie": MovieCount += sec.totalSize if sec.type == "show": @@ -610,7 +614,7 @@ class Plex: """ if not self._plex: return [] - # 过滤黑名单 + # 媒体库白名单 allow_library = ",".join([lib.id for lib in self.get_librarys()]) query = {'contentDirectoryID': allow_library} path = '/hubs/continueWatching/items' + utils.joinArgs(query)