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
This commit is contained in:
JonnyWong16 2023-07-27 18:08:46 -07:00 committed by GitHub
parent 8298a61b64
commit c5108b1115
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -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 @@ class LibraryMediaTag(PlexObject):
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')

View file

@ -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):