diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b936fa..89845c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - moved os.remove(session_cache_path()) inside try block to avoid TypeError on app.py example file - A warning will no longer be emitted when the cache file does not exist at the specified path - The docs for the `auth` parameter of `Spotify.init` use the term "access token" instead of "authorization token" +- Changed docs for `search` to mention that you can provide multiple types to search for +- The query parameters of requests are now logged + +### Added + +- Added log messages for when the access and refresh tokens are retrieved and when they are refreshed - Support `market` optional parameter in `track` ## [2.16.1] - 2020-10-24 diff --git a/spotipy/client.py b/spotipy/client.py index 232dc35..60e10b6 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -233,8 +233,8 @@ class Spotify(object): if self.language is not None: headers["Accept-Language"] = self.language - logger.debug('Sending %s to %s with Headers: %s and Body: %r ', - method, url, headers, args.get('data')) + logger.debug('Sending %s to %s with Params: %s Headers: %s and Body: %r ', + method, url, args.get("params"), headers, args.get('data')) try: response = self._session.request( @@ -535,10 +535,12 @@ class Spotify(object): Parameters: - q - the search query (see how to write a query in the official documentation https://developer.spotify.com/documentation/web-api/reference/search/search/) # noqa - - limit - the number of items to return (min = 1, default = 10, max = 50) + - limit - the number of items to return (min = 1, default = 10, max = 50). The limit is applied + within each type, not on the total response. - offset - the index of the first item to return - - type - the type of item to return. One of 'artist', 'album', - 'track', 'playlist', 'show', or 'episode' + - type - the types of items to return. One or more of 'artist', 'album', + 'track', 'playlist', 'show', and 'episode'. If multiple types are desired, + pass in a comma separated string; e.g., 'track,album,episode'. - market - An ISO 3166-1 alpha-2 country code or the string from_token. """ @@ -555,8 +557,8 @@ class Spotify(object): - limit - the number of items to return (min = 1, default = 10, max = 50). If a search is to be done on multiple markets, then this limit is applied to each market. (e.g. search US, CA, MX each with a limit of 10). - offset - the index of the first item to return - - type - the type's of item's to return. One or more of 'artist', 'album', - 'track', 'playlist', 'show', or 'episode'. If multiple types are desired, pass in a comma separated list. + - type - the types of items to return. One or more of 'artist', 'album', + 'track', 'playlist', 'show', or 'episode'. If multiple types are desired, pass in a comma separated string. - markets - A list of ISO 3166-1 alpha-2 country codes. Search all country markets by default. - total - the total number of results to return if multiple markets are supplied in the search. If multiple types are specified, this only applies to the first type. diff --git a/spotipy/oauth2.py b/spotipy/oauth2.py index c2eb8d6..c0b41ce 100644 --- a/spotipy/oauth2.py +++ b/spotipy/oauth2.py @@ -197,6 +197,11 @@ class SpotifyClientCredentials(SpotifyAuthBase): self.client_id, self.client_secret ) + logger.debug( + "sending POST request to %s with Headers: %s and Body: %r", + self.OAUTH_TOKEN_URL, headers, payload + ) + response = self._session.post( self.OAUTH_TOKEN_URL, data=payload, @@ -494,6 +499,11 @@ class SpotifyOAuth(SpotifyAuthBase): headers = self._make_authorization_headers() + logger.debug( + "sending POST request to %s with Headers: %s and Body: %r", + self.OAUTH_TOKEN_URL, headers, payload + ) + response = self._session.post( self.OAUTH_TOKEN_URL, data=payload, @@ -529,6 +539,11 @@ class SpotifyOAuth(SpotifyAuthBase): headers = self._make_authorization_headers() + logger.debug( + "sending POST request to %s with Headers: %s and Body: %r", + self.OAUTH_TOKEN_URL, headers, payload + ) + response = self._session.post( self.OAUTH_TOKEN_URL, data=payload, @@ -836,8 +851,8 @@ class SpotifyPKCE(SpotifyAuthBase): Parameters: - code - the response code from authentication - - check_cache - if true, checks for locally stored token - before requesting a new token if True + - check_cache - if true, checks for a locally stored token + before requesting a new token """ if check_cache: @@ -862,6 +877,11 @@ class SpotifyPKCE(SpotifyAuthBase): headers = {"Content-Type": "application/x-www-form-urlencoded"} + logger.debug( + "sending POST request to %s with Headers: %s and Body: %r", + self.OAUTH_TOKEN_URL, headers, payload + ) + response = self._session.post( self.OAUTH_TOKEN_URL, data=payload, @@ -892,6 +912,11 @@ class SpotifyPKCE(SpotifyAuthBase): headers = {"Content-Type": "application/x-www-form-urlencoded"} + logger.debug( + "sending POST request to %s with Headers: %s and Body: %r", + self.OAUTH_TOKEN_URL, headers, payload + ) + response = self._session.post( self.OAUTH_TOKEN_URL, data=payload,