mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 01:03:53 +00:00
Added more logging and fixed docs for search endpoint (#609)
* Added an exception clause that catches `FileNotFoundError` and logs a debug message in `SpotifyOAuth.get_cached_token`, `SpotifyPKCE.get_cached_token` and `SpotifyImplicitGrant.get_cached_token`. * Changed docs for `auth` parameter of `Spotify.init` to `access token` instead of `authorization token`. In issue #599, a user confused the access token with the authorization code. * Updated CHANGELOG.md * Removed `FileNotFoundError` because it does not exist in python 2.7 (*sigh*) and replaced it with a call to `os.path.exists`. * Replaced ` os.path.exists` with `error.errno == errno.ENOENT` to supress errors when the cache file does not exist. * Changed docs for `search` to mention that you can provide multiple multiple types to search for. The query parameters of requests are now logged. Added log messages for when the access token and refresh tokens are retrieved and when they are refreshed. Other small grammar fixes. * Removed duplicate word "multiple" from CHANGELOG Co-authored-by: Stéphane Bruckert <stephane.bruckert@gmail.com>
This commit is contained in:
parent
7531d141c0
commit
94e164385e
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user