From 48401c60dc9464bddc8e15f8e379480ba8b3e90f Mon Sep 17 00:00:00 2001 From: Rahul Ahuja Date: Mon, 21 Jan 2019 22:27:31 -0800 Subject: [PATCH] Switch query filter ordering for tests --- beetsplug/spotify.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/beetsplug/spotify.py b/beetsplug/spotify.py index 152bea46d..ee73640ae 100644 --- a/beetsplug/spotify.py +++ b/beetsplug/spotify.py @@ -320,6 +320,8 @@ class SpotifyPlugin(BeetsPlugin): response_data = self._search_spotify( query_type='album', filters=query_filters ) + if response_data is None: + return [] return [ self.album_for_id(album_id=album_data['id']) for album_data in response_data['albums']['items'] @@ -332,6 +334,8 @@ class SpotifyPlugin(BeetsPlugin): response_data = self._search_spotify( query_type='track', keywords=title, filters={'artist': artist} ) + if response_data is None: + return [] return [ self.track_for_id(track_data=track_data) for track_data in response_data['tracks']['items'] @@ -469,7 +473,7 @@ class SpotifyPlugin(BeetsPlugin): keywords = item[self.config['track_field'].get()] # Query the Web API for each track, look for the items' JSON data - query_filters = {'artist': artist, 'album': album} + query_filters = {'album': album, 'artist': artist} response_data = self._search_spotify( query_type='track', keywords=keywords, filters=query_filters )