[GH-ISSUE #925] show_episodes adding superfluous / to URI #555

Open
opened 2026-02-27 23:23:18 +03:00 by kerem · 4 comments
Owner

Originally created by @stevereaver on GitHub (Jan 3, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/925

Describe the bug
When requesting a show list using show_episodes the URI that is used seems to be;
https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes/?limit=50&offset=0

However if the same request is done with a curl the URI used is;
https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes?offset=0&limit=20

NOTE: spotipy adds and addtional / after episodes, which breaks the URI and results in a 404

CURL Command

curl -X "GET" "https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Python Code

import spotipy
from spotipy.oauth2 import SpotifyClientCredentials

uri = 'spotify:show:47Xw6QagBN5lTAp1Cyoyye'
spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())

results = spotify.show_episodes(uri)

Expected behavior
As per description above

Output From Python

HTTP Error for GET to https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes/ with Params: {'limit': 50, 'offset': 0, 'market': None} returned 404 due to non existing id
Traceback (most recent call last):
  File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 245, in _internal_call
    response.raise_for_status()
  File "/home/reaver/.local/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes/?limit=50&offset=0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./get-show-list.py", line 10, in <module>
    results = spotify.show_episodes(uri)
  File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 512, in show_episodes
    return self._get(
  File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 297, in _get
    return self._internal_call("GET", url, payload, kwargs)
  File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 267, in _internal_call
    raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes/?limit=50&offset=0:
 non existing id, reason: None

Output From CURL

{
  "href": "https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes?offset=0&limit=20",
  "items": [
    {
      "audio_preview_url": "https://p.scdn.co/mp3-preview/5f44c3e9375fba9b9d273188eafd79f6f4879fa6",
      "description": "In this episode we discuss; ACCC Drop Case, Show Stats, Chat GPT, Favourite Moment, Tech Predictions, Look Back & Highlights",
      "duration_ms": 3495741,
      "explicit": false,
      "external_urls": {
        "spotify": "https://open.spotify.com/episode/3upuqsUV79ZA8ygqdXQEqK"
      },
      "href": "https://api.spotify.com/v1/episodes/3upuqsUV79ZA8ygqdXQEqK",
      "html_description": "<p>“Predict like an AI” In this episode we discuss; ACCC Drop Case, Show Stats,
...

NOTE: The different URI's in each output above.

Environment:

  • Linux Ubuntu 20.04
  • Python version 3.8.10
  • spotipy version 2.21.0
  • IDE vscode

Additional context
Add any other context about the problem here.

Originally created by @stevereaver on GitHub (Jan 3, 2023). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/925 **Describe the bug** When requesting a show list using show_episodes the URI that is used seems to be; https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes/?limit=50&offset=0 However if the same request is done with a curl the URI used is; https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes?offset=0&limit=20 NOTE: spotipy adds and addtional / after episodes, which breaks the URI and results in a 404 **CURL Command** ```bash curl -X "GET" "https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ``` **Python Code** ```python3 import spotipy from spotipy.oauth2 import SpotifyClientCredentials uri = 'spotify:show:47Xw6QagBN5lTAp1Cyoyye' spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials()) results = spotify.show_episodes(uri) ``` **Expected behavior** As per description above **Output From Python** ``` HTTP Error for GET to https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes/ with Params: {'limit': 50, 'offset': 0, 'market': None} returned 404 due to non existing id Traceback (most recent call last): File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 245, in _internal_call response.raise_for_status() File "/home/reaver/.local/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes/?limit=50&offset=0 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "./get-show-list.py", line 10, in <module> results = spotify.show_episodes(uri) File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 512, in show_episodes return self._get( File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 297, in _get return self._internal_call("GET", url, payload, kwargs) File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 267, in _internal_call raise SpotifyException( spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes/?limit=50&offset=0: non existing id, reason: None ``` **Output From CURL** ```json { "href": "https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes?offset=0&limit=20", "items": [ { "audio_preview_url": "https://p.scdn.co/mp3-preview/5f44c3e9375fba9b9d273188eafd79f6f4879fa6", "description": "In this episode we discuss; ACCC Drop Case, Show Stats, Chat GPT, Favourite Moment, Tech Predictions, Look Back & Highlights", "duration_ms": 3495741, "explicit": false, "external_urls": { "spotify": "https://open.spotify.com/episode/3upuqsUV79ZA8ygqdXQEqK" }, "href": "https://api.spotify.com/v1/episodes/3upuqsUV79ZA8ygqdXQEqK", "html_description": "<p>“Predict like an AI” In this episode we discuss; ACCC Drop Case, Show Stats, ... ``` NOTE: The different URI's in each output above. **Environment:** - Linux Ubuntu 20.04 - Python version 3.8.10 - spotipy version 2.21.0 - IDE vscode **Additional context** Add any other context about the problem here.
Author
Owner

@stevereaver commented on GitHub (Jan 3, 2023):

I've spun up my own branch and removed the /, however the error still persists. This has got me really puzzled.

HTTP Error for GET to https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes with Params: {'limit': 20, 'offset': 0, 'market': None} returned 404 due to non existing id
Traceback (most recent call last):
  File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 245, in _internal_call
    response.raise_for_status()
  File "/home/reaver/.local/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes?limit=20&offset=0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./code.py", line 7, in <module>
    results = spotify.show_episodes(uri)
  File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 512, in show_episodes
    return self._get(
  File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 297, in _get
    return self._internal_call("GET", url, payload, kwargs)
  File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 267, in _internal_call
    raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes?limit=20&offset=0:
 non existing id, reason: None
<!-- gh-comment-id:1369419610 --> @stevereaver commented on GitHub (Jan 3, 2023): I've spun up my own branch and removed the /, however the error still persists. This has got me really puzzled. ``` HTTP Error for GET to https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes with Params: {'limit': 20, 'offset': 0, 'market': None} returned 404 due to non existing id Traceback (most recent call last): File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 245, in _internal_call response.raise_for_status() File "/home/reaver/.local/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes?limit=20&offset=0 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "./code.py", line 7, in <module> results = spotify.show_episodes(uri) File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 512, in show_episodes return self._get( File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 297, in _get return self._internal_call("GET", url, payload, kwargs) File "/home/reaver/.local/lib/python3.8/site-packages/spotipy/client.py", line 267, in _internal_call raise SpotifyException( spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/shows/47Xw6QagBN5lTAp1Cyoyye/episodes?limit=20&offset=0: non existing id, reason: None ```
Author
Owner

@dieser-niko commented on GitHub (Jan 3, 2023):

Not quite sure why, but if you use SpotifyOAuth (no scopes) instead of SpotifyClientCredentials, it seems to work just fine. So my guess is that this is a problem on Spotifys side.

Also, I made an interesting discovery: when I request a token in the Spotify Developer Console, it asks for the "user-read-playback-position" scope, but it seems to work just fine without scopes. The (obvious) difference is a missing playback position for each episode. Maybe Spotify has restricted access to this endpoint only because of this optional scope, but that's just a theory.

<!-- gh-comment-id:1369777663 --> @dieser-niko commented on GitHub (Jan 3, 2023): Not quite sure why, but if you use SpotifyOAuth (no scopes) instead of SpotifyClientCredentials, it seems to work just fine. So my guess is that this is a problem on Spotifys side. Also, I made an interesting discovery: when I request a token in the [Spotify Developer Console](https://developer.spotify.com/console/get-show-episodes/?id=47Xw6QagBN5lTAp1Cyoyye&market=&limit=&offset=), it asks for the "user-read-playback-position" scope, but it seems to work just fine without scopes. The (obvious) difference is a missing playback position for each episode. Maybe Spotify has restricted access to this endpoint only because of this optional scope, but that's just a theory.
Author
Owner

@dieser-niko commented on GitHub (Jan 3, 2023):

And where did you get your token when using cURL?

<!-- gh-comment-id:1369780046 --> @dieser-niko commented on GitHub (Jan 3, 2023): And where did you get your token when using cURL?
Author
Owner

@stevereaver commented on GitHub (Jan 4, 2023):

And where did you get your token when using cURL?

The token was generated on the spotify developer console.

<!-- gh-comment-id:1370372777 --> @stevereaver commented on GitHub (Jan 4, 2023): > And where did you get your token when using cURL? The token was generated on the spotify developer console.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#555
No description provided.