From 4dfbabf679e52c3acff22b41da0ac1983c96fb5e Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 5 Apr 2022 22:14:32 -0400 Subject: [PATCH] [9] #667 Allow other actors in filters --- VERSION | 2 +- modules/builder.py | 23 ++++++++++++++++------- modules/plex.py | 8 ++++++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/VERSION b/VERSION index b5589522..1da51515 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.3-develop8 +1.16.3-develop9 diff --git a/modules/builder.py b/modules/builder.py index 42c5cc0e..a7774ef7 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -1813,13 +1813,22 @@ class CollectionBuilder: else: valid_list.append(search_choices[str(value).lower()]) else: - error = f"Plex Error: {attribute}: {value} not found" - if self.details["show_options"]: - error += f"\nOptions: {names}" - if validate: - raise Failed(error) - else: - logger.error(error) + actor_id = None + if attribute in ["actor", "director", "producer", "writer"]: + actor_id = self.library.get_actor_id(value) + if actor_id: + if pairs: + valid_list.append((value, actor_id)) + else: + valid_list.append(actor_id) + if not actor_id: + error = f"Plex Error: {attribute}: {value} not found" + if self.details["show_options"]: + error += f"\nOptions: {names}" + if validate: + raise Failed(error) + else: + logger.error(error) return valid_list elif attribute in plex.date_attributes and modifier in [".before", ".after"]: if data == "today": diff --git a/modules/plex.py b/modules/plex.py index 3725cbd3..a8560127 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -8,6 +8,7 @@ from plexapi import utils from plexapi.audio import Artist, Track, Album from plexapi.exceptions import BadRequest, NotFound, Unauthorized from plexapi.collection import Collection +from plexapi.library import Actor from plexapi.playlist import Playlist from plexapi.server import PlexServer from plexapi.video import Movie, Show, Season, Episode @@ -568,6 +569,13 @@ class Plex(Library): item.uploadPoster(filepath=image) self.reload(item) + @retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_failed) + def get_actor_id(self, name): + results = self.Plex.hubSearch(name) + for result in results: + if isinstance(result, Actor) and result.librarySectionID == self.Plex.key and result.tag == name: + return result.id + @retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_failed) def get_search_choices(self, search_name, title=True): final_search = search_translation[search_name] if search_name in search_translation else search_name