spotify-downloader: SpotifyException HTTP404 Error, HTTP Error for GET - Cannot download songs
System Operating System (OS)
Linux
Python Version
3.8 (CPython)
Install Source
GitHub
Install version / commit hash
3.9.4
Expected Behavior vs Actual Behavior
I was trying to download a playlist containing a bigger amount of songs. I noticed that while fetching the names and looking them up on YouTube, I got random HTTP 404 on requests going to Spotify. With every run, it randomly appears on songs, that definitely exist (I checked the URL manually).
I’m guessing, that there is a rate limit or something similar on Spotify’s end.
My suggestion - that I also already tested locally - would be to retry the failed requests instead of exiting out and to continue downloading the rest instead of just failing.
Steps to reproduce
- Try to download a huge playlist
Traceback
Traceback (most recent call last):
File "/**/venv/lib/python3.8/site-packages/spotipy/client.py", line 245, in _internal_call
response.raise_for_status()
File "/**/venv/lib/python3.8/site-packages/requests/models.py", line 960, 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/tracks/22ea9e9wspXjaR7qfqfsdS
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/**/venv/bin/spotdl", line 8, in <module>
sys.exit(console_entry_point())
File "/**/venv/lib/python3.8/site-packages/spotdl/console/__init__.py", line 78, in console_entry_point
song_list = parse_query(
File "/**/venv/lib/python3.8/site-packages/spotdl/parsers/query_parser.py", line 29, in parse_query
parse_request(
File "/**/venv/lib/python3.8/site-packages/spotdl/parsers/query_parser.py", line 107, in parse_request
song_list = song_gatherer.from_playlist(
File "/**/venv/lib/python3.8/site-packages/spotdl/search/song_gatherer.py", line 359, in from_playlist
for result in results:
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 619, in result_iterator
yield fs.pop().result()
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 437, in result
return self.__get_result()
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
raise self._exception
File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/**/venv/lib/python3.8/site-packages/spotdl/search/song_gatherer.py", line 320, in get_song
song = from_spotify_url(
File "/**/venv/lib/python3.8/site-packages/spotdl/search/song_gatherer.py", line 43, in from_spotify_url
raw_track_meta, raw_artist_meta, raw_album_meta = metadata_provider.from_url(
File "/**/venv/lib/python3.8/site-packages/spotdl/providers/metadata_provider.py", line 11, in from_url
raw_track_meta = spotify_client.track(spotify_url)
File "/**/venv/lib/python3.8/site-packages/spotipy/client.py", line 345, in track
return self._get("tracks/" + trid, market=market)
File "/**/venv/lib/python3.8/site-packages/spotipy/client.py", line 297, in _get
return self._internal_call("GET", url, payload, kwargs)
File "/**/venv/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/tracks/22ea9e9wspXjaR7qfqfsdS:
None, reason: None
Other details
Easy to go solution would be to wrap “from_url” with the “retry” decorator (https://pypi.org/project/retry/)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (3 by maintainers)
it’s already fixed on
devbranch. I will release new update later today.Keep in mind that it’s only a temporary fix, I will investigate this issue more thoroughly later this week
Update spotDL from dev
pip uninstall spotdlpip install -U https://codeload.github.com/spotDL/spotify-downloader/zip/devFor me both “workarrounds” do not work. I got the same error on all playlists with more the 3 or 4 items …
Maybe it is a restriction on spotify API.
Before I got this error I use the params
–dt 20 --st 10
Now I try with:
–dt 1 --st 1
and everything works fine. no 404 errors
new version has been released with a fix. Please update
pip install -U spotdlIn my opinion, spotfify-download should handle the http404 or SpotifyException instead just exciting out.
spotify_client.track(spotify_url)Is basically an GET request method.To everyone in this thread, doing the following has seemed to work with a playlist of 39 songs:
Navigate to your working directory (where you are running spotDL) and delete the .spotdl-cache file, then try again
In Windows, the default working directory is your user folder C:\Users\yourname\
Hello, guys. I don’t know if it might be the problem, but make sure your Playlist is in “Public”. I just changed mine from “Private” to “Public”, and it managed to download the songs. I still get some 404 of some songs, tho, but I think that’s common as some of them are not in YouTube.
Navigate to your working directory (where you are running spotDL) and delete the
.spotdl-cachefile, then try againIn Windows, the default working directory is your user folder
C:\Users\yourname\You can also try reinstall spotDL & its dependencies
pip install -U --force spotdl