Skip to content

Commit

Permalink
Add score and tagKey attribute to hub search results (#1186)
Browse files Browse the repository at this point in the history
* Add `score` and `tagKey` attribute to hub search results

* Update tests for hub search result `score` and `tagKey` attributes
  • Loading branch information
JonnyWong16 authored Jul 28, 2023
1 parent 8298a61 commit c5108b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions plexapi/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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')
Expand Down
6 changes: 5 additions & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit c5108b1

Please sign in to comment.