From c5108b1115805f3929155d85394664914cb0cd71 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Thu, 27 Jul 2023 18:08:46 -0700 Subject: [PATCH] Add `score` and `tagKey` attribute to hub search results (#1186) * Add `score` and `tagKey` attribute to hub search results * Update tests for hub search result `score` and `tagKey` attributes --- plexapi/library.py | 4 ++++ tests/test_server.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/plexapi/library.py b/plexapi/library.py index e80e2a276..2fc87c553 100644 --- a/plexapi/library.py +++ b/plexapi/library.py @@ -2211,8 +2211,10 @@ class LibraryMediaTag(PlexObject): reason (str): The reason for the search result. reasonID (int): The reason ID for the search result. reasonTitle (str): The reason title for the search result. + score (float): The score for the search result. type (str): The type of search result (tag). tag (str): The title of the tag. + tagKey (str): The Plex Discover ratingKey (guid) for people. tagType (int): The type ID of the tag. tagValue (int): The value of the tag. thumb (str): The URL for the thumbnail of the tag (if available). @@ -2233,8 +2235,10 @@ def _loadData(self, data): self.reason = data.attrib.get('reason') self.reasonID = utils.cast(int, data.attrib.get('reasonID')) self.reasonTitle = data.attrib.get('reasonTitle') + self.score = utils.cast(float, data.attrib.get('score')) self.type = data.attrib.get('type') self.tag = data.attrib.get('tag') + self.tagKey = data.attrib.get('tagKey') self.tagType = utils.cast(int, data.attrib.get('tagType')) self.tagValue = utils.cast(int, data.attrib.get('tagValue')) self.thumb = data.attrib.get('thumb') diff --git a/tests/test_server.py b/tests/test_server.py index 5fc6f5c9d..e1bcf9ffb 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -144,6 +144,7 @@ def test_server_search(plex, movie): assert hub_tag.reason == "section" assert hub_tag.reasonID == hub_tag.librarySectionID assert hub_tag.reasonTitle == hub_tag.librarySectionTitle + assert utils.is_float(hub_tag.score, gte=0.0) assert hub_tag.type == "tag" assert hub_tag.tag == genre.tag assert hub_tag.tagType == 1 @@ -155,7 +156,10 @@ def test_server_search(plex, movie): assert plex.search(director.tag, mediatype="director") # Test actor search role = movie.roles[0] - assert plex.search(role.tag, mediatype="actor") + results = plex.search(role.tag, mediatype="actor") + assert results + hub_tag = results[0] + assert hub_tag.tagKey def test_server_playlist(plex, show):