Skip to content

Commit

Permalink
Fix search3 results generation
Browse files Browse the repository at this point in the history
Previous version would raise KeyError if any of artist, album, or song
were empty in results.

Signed-off-by: Eric B Munson <[email protected]>
  • Loading branch information
khers committed Jan 11, 2024
1 parent c856e11 commit dde0351
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
##2.0.1

Fix result parsing in search3, allow for empty artist, album, or song field.

## 2.0.0

Create objects for many of the returns from the api end points and rewored Connection object to use these new classes.
Expand Down
2 changes: 1 addition & 1 deletion src/libopensonic/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@


#Semantic versioning string for the library
__version__ = '2.0.0'
__version__ = '2.0.1'
16 changes: 10 additions & 6 deletions src/libopensonic/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,16 @@ def search3(self, query, artistCount=20, artistOffset=0, albumCount=20,
res = self._doInfoReq(req)
self._checkStatus(res)
found = {'artists': [], 'albums': [], 'songs': []}
for entry in res['searchResults3']['artist']:
found['artists'].append(Artist(entry))
for entry in res['searchResults3']['album']:
found['albums'].append(Album(entry))
for entry in res['searchResults3']['song']:
found['songs'].append(Song(entry))
print(str(res))
if 'artist' in res['searchResult3']:
for entry in res['searchResult3']['artist']:
found['artists'].append(Artist(entry))
if 'album' in res['searchResult3']:
for entry in res['searchResult3']['album']:
found['albums'].append(Album(entry))
if 'song' in res['searchResult3']:
for entry in res['searchResult3']['song']:
found['songs'].append(Song(entry))
return found


Expand Down

0 comments on commit dde0351

Please sign in to comment.