Replies: 2 comments 1 reply
|
Okay, it seemed strange to me because I had just tried with 2 playlists yesterday... but I did manage to reproduce your error. Indeed, when trying to download or inspect a playlist using the CLI (which is where I usually solve most problems), I got the same error: 2025-11-15 21:21:23,652 [INFO] SpotifyAPI: Fetching playlist data: https://open.spotify.com/playlist/37i9dQZF1DX3R7OWWGN4gH?si=d262b75de0d0450c
2025-11-15 21:21:24,797 [ERROR] spotipy.client: HTTP Error for GET to https://api.spotify.com/v1/playlists/37i9dQZF1DX3R7OWWGN4gH with Params: {'fields': None, 'market': None, 'additional_types': 'track'} returned 404 due to Resource not found
2025-11-15 21:21:24,797 [ERROR] SpotifyAPI: Error fetching playlist data: http status: 404, code: -1 - https://api.spotify.com/v1/playlists/37i9dQZF1DX3R7OWWGN4gH?additional_types=track:
Resource not found, reason: NoneOriginally we extracted the data from the @lru_cache(maxsize=32)
def _fetch_playlist_data(self, playlist_url: str) -> dict:
try:
self.logger.info(f"Fetching playlist data: {playlist_url}")
return self.sp.playlist(playlist_url)
except spotipy.exceptions.SpotifyException as e:
self.logger.error(f"Error fetching playlist data: {e}")
raise ValueError("Playlist not found or invalid URL") from eThe solution I can think of (and which I will extend to all Spotify client query methods) is to parse the URL to obtain only the ID (for track, album, artist, or playlist)... I've tested it and it seems to work well. We'll try two methods just in case, one using urllib.parse and the other using regex. For now, I'll stick with the regex method: def _extract_spotify_id(self, url: str) -> Optional[str]:
"""
Extrack the ID from a Spotify URL. It uses regex.
Args:
url (str): Spotify URL of a Track, Artist, Album or Playlist
Returns:
id (Optional[str]): id of the item or None if not found
"""
pattern = r"(?:track|artist|album|playlist)/([A-Za-z0-9]+)"
match = re.search(pattern, url)
return match.group(1) if match else None
@lru_cache(maxsize=32)
def _fetch_playlist_data(self, playlist_url: str) -> dict:
"""Fetch raw playlist data from the API.
Args:
playlist_url: Spotify URL or URI for the playlist
Returns:
dict: Raw playlist data from Spotify API
Raises:
ValueError: If playlist is not found or URL is invalid
"""
try:
self.logger.info(f"Fetching playlist data: {playlist_url}")
playlist_id = self._extract_spotify_id(playlist_url)
if not playlist_id:
raise ValueError("Invalid playlist URL")
return self.sp.playlist(playlist_id)
except spotipy.exceptions.SpotifyException as e:
self.logger.error(f"Error fetching playlist data: {e}")
raise ValueError("Playlist not found or invalid URL") from eI hope this solves the problem and that it will be available in the next release! We'll create a pull request if you prefer to clone the repository and build directly! @giwty if you can, could you create an issue about this? |

Uh oh!
There was an error while loading. Please reload this page.
Getting
spotifysaver | 2025-11-15T19:20:42.652452403Z HTTP Error for GET to https://api.spotify.com/v1/playlists/37i9dQZF1DWWiDhnQ2IIru with Params: {'fields': None, 'market': None, 'additional_types': 'track'} returned 404 due to Resource not found spotifysaver | 2025-11-15T19:20:42.652482756Z Error fetching playlist data: http status: 404, code: -1 - https://api.spotify.com/v1/playlists/37i9dQZF1DWWiDhnQ2IIru?additional_types=track: spotifysaver | 2025-11-15T19:20:42.652487529Z Resource not found, reason: None spotifysaver | 2025-11-15T19:20:42.652490156Z Error inspecting URL https://open.spotify.com/playlist/37i9dQZF1DWWiDhnQ2IIru?si=diUJ8xnASNuFeN5S_mtE7g: Playlist not found or invalid URL spotifysaver | 2025-11-15T19:20:42.652724598Z INFO: 192.168.1.54:51989 - "GET /api/v1/inspect?spotify_url=https%3A%2F%2Fopen.spotify.com%2Fplaylist%2F37i9dQZF1DWWiDhnQ2IIru%3Fsi%3DdiUJ8xnASNuFeN5S_mtE7g HTTP/1.1" 500 Internal Server ErrorThis is a public playlist
All reactions