Closed olistori closed 1 month ago
What does playlist_id
print?
3ntvwrQ3TSHo2k3wFjN62s i guess its the id for the playlist
on .track ive tried the url, id and ur:
try:
track = spotify.track(query)
except Exception as e:
print(f"An error occurred: {e}")
logging.error(f"An error occurred: {e}")
Okay strange, could you please share the full stack trace you are seeing?
When i put logging level in DEBUG, this is all i get when i try to call the functions:
DEBUG:spotipy.cache_handler:cache does not exist at: .cache DEBUG:spotipy.cache_handler:cache does not exist at: .cache ERROR:root:An error occurred: can only concatenate tuple (not "str") to tuple
The stack trace shows the exact line where there is an issue, could you share that? It's basically the full error you are seeing, please copy paste everything you see
Edit: I just saw you are swallowing the error. To see the full error in here you need to either 1) remove the whole try/except
track = spotify.track(query)
or 2) throw the error again:
try:
track = spotify.track(query)
except Exception as e:
print(f"An error occurred: {e}")
logging.error(f"An error occurred: {e}")
throw(e)
or 3) print the stack trace from Except https://stackoverflow.com/a/16946886/1515819:
import traceback
try:
track = spotify.track(query)
except Exception as e:
print(f"An error occurred: {e}")
logging.error(f"An error occurred: {e}")
traceback.print_exc()
Ahh i see, the error is not with the function call. Looks like its with my credentials
An error occurred: can only concatenate tuple (not "str") to tuple Traceback (most recent call last): File "C:\Users\plexy\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotipy\client.py", line 242, in _auth_headers token = self.auth_manager.get_access_token(as_dict=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\plexy\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotipy\oauth2.py", line 229, in get_access_token token_info = self._request_access_token() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\plexy\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotipy\oauth2.py", line 238, in _request_access_token headers = _make_authorization_headers( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\plexy\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotipy\oauth2.py", line 53, in _make_authorization_headers str(client_id + ":" + client_secret).encode("ascii")
TypeError: can only concatenate tuple (not "str") to tuple
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\plexy\Desktop\Discord Bot\Discord-bot-pip\Discord_bot.py", line 318, in play
track = spotify.track(query)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\plexy\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotipy\client.py", line 375, in track
return self._get("tracks/" + trid, market=market)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\plexy\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotipy\client.py", line 327, in _get
return self._internal_call("GET", url, payload, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\plexy\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotipy\client.py", line 251, in _internal_call
headers = self._auth_headers()
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\plexy\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotipy\client.py", line 244, in _auth_headers
token = self.auth_manager.get_access_token()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\plexy\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotipy\oauth2.py", line 229, in get_access_token
token_info = self._request_access_token()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\plexy\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotipy\oauth2.py", line 238, in _request_access_token
headers = _make_authorization_headers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\plexy\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotipy\oauth2.py", line 53, in _make_authorization_headers
str(client_id + ":" + client_secret).encode("ascii")
~~~~~~~~~~^~~~~
TypeError: can only concatenate tuple (not "str") to tuple
this is how i set the credentials:
```
spotify = spotipy.Spotify(
client_credentials_manager=SpotifyClientCredentials(
client_id=SPOTIFY_CLIENT_ID,
client_secret=SPOTIFY_CLIENT_SECRET
)
)
```
It was a problem with my credential files, its contained extra "," after each credential. it fixed the problem. Sorry to bother
Think there is a problem with how spotipy is handling strings in some functions. Atleast .track() and .playlist_tracks() here is a code snipped im using, query is a link to a spotify playlist.
ive tried using URL, URI and Playlist/track id
Output An error occurred: can only concatenate tuple (not "str") to tuple
Environment: