Fix searchDiscover handling invalid results (#1013)

* Filter out bad discover search results

An stub object is sometimes returned from the API that is marked as
`'external'` but has has no `'SearchResults'` key.

    {'id': 'external', 'title': 'More Ways To Watch', 'size': 0}

* Wrap line to fit 127c

* Ensure empty array for SearchResult
This commit is contained in:
Joshua Peek 2022-08-27 06:24:10 -07:00 committed by GitHub
parent 4d9e1d4f14
commit fbc124aa57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -899,7 +899,7 @@ class MyPlexAccount(PlexObject):
data = self.query(f'{self.METADATA}/library/search', headers=headers, params=params)
searchResults = data['MediaContainer'].get('SearchResults', [])
searchResult = next((s['SearchResult'] for s in searchResults if s.get('id') == 'external'), [])
searchResult = next((s.get('SearchResult', []) for s in searchResults if s.get('id') == 'external'), [])
results = []
for result in searchResult: