Simplify get watched process. Only get watched for syncing libraries

Signed-off-by: Luis Garcia <git@luigi311.com>
This commit is contained in:
Luis Garcia
2024-10-27 13:43:09 -06:00
parent 8428be9dda
commit bc09c873e9
5 changed files with 185 additions and 155 deletions

View File

@@ -466,14 +466,28 @@ class Plex:
logger(f"Plex: Failed to get users, Error: {e}", 2)
raise Exception(e)
def get_libraries(self):
try:
output = {}
libraries = self.plex.library.sections()
for library in libraries:
library_title = library.title
library_type = library.type
output[library_title] = library_type
return output
except Exception as e:
logger(f"Plex: Failed to get libraries, Error: {e}", 2)
raise Exception(e)
def get_watched(
self,
users,
blacklist_library,
whitelist_library,
blacklist_library_type,
whitelist_library_type,
library_mapping,
sync_libraries
):
try:
# Get all libraries
@@ -500,23 +514,7 @@ class Plex:
libraries = user_plex.library.sections()
for library in libraries:
library_title = library.title
library_type = library.type
skip_reason = check_skip_logic(
library_title,
library_type,
blacklist_library,
whitelist_library,
blacklist_library_type,
whitelist_library_type,
library_mapping,
)
if skip_reason:
logger(
f"Plex: Skipping library {library_title}: {skip_reason}", 1
)
if library.title not in sync_libraries:
continue
user_watched = get_user_library_watched(user, user_plex, library)