mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #1151] An error occurred: can only concatenate tuple (not "str") to tuple when using Spotipy functions #678
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#678
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @olistori on GitHub (Jul 28, 2024).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1151
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:
@stephanebruckert commented on GitHub (Jul 28, 2024):
What does
playlist_idprint?@olistori commented on GitHub (Jul 28, 2024):
3ntvwrQ3TSHo2k3wFjN62s i guess its the id for the playlist
on .track ive tried the url, id and ur:
@stephanebruckert commented on GitHub (Jul 28, 2024):
Okay strange, could you please share the full stack trace you are seeing?
@olistori commented on GitHub (Jul 28, 2024):
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
@stephanebruckert commented on GitHub (Jul 28, 2024):
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
or 2) throw the error again:
or 3) print the stack trace from Except https://stackoverflow.com/a/16946886/1515819:
@olistori commented on GitHub (Jul 28, 2024):
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:
@olistori commented on GitHub (Jul 28, 2024):
It was a problem with my credential files, its contained extra "," after each credential. it fixed the problem. Sorry to bother