diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d80207..397f798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/libopensonic/_version.py b/src/libopensonic/_version.py index 714da6e..8f563b4 100644 --- a/src/libopensonic/_version.py +++ b/src/libopensonic/_version.py @@ -17,4 +17,4 @@ #Semantic versioning string for the library -__version__ = '2.0.0' +__version__ = '2.0.1' diff --git a/src/libopensonic/connection.py b/src/libopensonic/connection.py index b112a87..b34fa12 100644 --- a/src/libopensonic/connection.py +++ b/src/libopensonic/connection.py @@ -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