spotify-downloader: Download error: KeyError: 'playNavigationEndpoint'

In the evening I started downloading two playlists, they downloaded normally. In the morning I start downloading the next playlist and get an error:

Fetching Playlist...                                                                                                                                                                                                                  
Traceback (most recent call last):
File "/root/envspotdl/bin/spotdl", line 8, in <module>
sys.exit(console_entry_point())
File "/root/envspotdl/lib/python3.8/site-packages/spotdl/__main__.py", line 114, in console_entry_point
 songObjList = get_playlist_tracks(request)
File "/root/envspotdl/lib/python3.8/site-packages/spotdl/search/utils.py", line 82, in get_playlist_tracks
 song = SongObj.from_url(
File "/root/envspotdl/lib/python3.8/site-packages/spotdl/search/songObj.py", line 66, in from_url
  youtubeLink = SongObj.searchProvider(
File "/root/envspotdl/lib/python3.8/site-packages/spotdl/search/provider.py", line 478, in search_and_get_best_match
 results = search_and_order_ytm_results(
File "/root/envspotdl/lib/python3.8/site-packages/spotdl/search/provider.py", line 366, in search_and_order_ytm_results
  results = __query_and_simplify(songSearchStr)
File "/root/envspotdl/lib/python3.8/site-packages/spotdl/search/provider.py", line 176, in __query_and_simplify
  linkBlock = contents['musicResponsiveListItemRenderer'] \
KeyError: 'playNavigationEndpoint'

I installed spotdl like this:

pip3 install spotdl
pip3 uninstall -y pytube3
pip3 install git+https://github.com/nficano/pytube

other installation options did not solve the problem. When installing from master branch, I get another error: TypeError: cannot unpack non-iterable NoneType object

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Also, it could be a bad idea to wrap that whole thing

Yup, You’re right. Will make the suggested changes.

Please close this issue, if this fixes it.

It could be a good idea to put an error message there too; not sure how the rest of the program handles errors. Also, it could be a bad idea to wrap that whole thing. If there’s an error in the future regarding any of those keys, we would never be able to know. Maybe we can do something like this:

_linkBlock = contents['musicResponsiveListItemRenderer'] \
        ['overlay'] \
            ['musicItemThumbnailOverlayRenderer'] \
                ['content'] \
                    ['musicPlayButtonRenderer']
try:
    linkBlock = _linkBlock ['playNavigationEndpoint']
except KeyError:
    continue

Now I get both errors at once, a complete list of what I did:

> python3.8 -m venv master
> source master/bin/activate
> pip install pip-autoremove
> pip-autoremove spotdl
> pip install https://codeload.github.com/spotDL/spotify-downloader/zip/master
> pip uninstall pytube
> pip install git+https://github.com/nficano/pytube
> spotdl https://open.spotify.com/playlist/3lsjGhv5VTN0mjnmDP3HI9?si=1Y6rH7qCRJq8k1H7RSpJOw
> 
> Fetching Playlist...                                                                                                                                                                                                                  
> Traceback (most recent call last):
>   File "/root/master/bin/spotdl", line 33, in <module>
>     sys.exit(load_entry_point('spotdl==3.1.4', 'console_scripts', 'spotdl')())
>   File "/root/master/lib/python3.8/site-packages/spotdl/__main__.py", line 111, in console_entry_point
>     songObjList = get_playlist_tracks(request)
>   File "/root/master/lib/python3.8/site-packages/spotdl/search/utils.py", line 82, in get_playlist_tracks
>     song = SongObj.from_url(
>   File "/root/master/lib/python3.8/site-packages/spotdl/search/songObj.py", line 66, in from_url
>     youtubeLink = SongObj.searchProvider(
>   File "/root/master/lib/python3.8/site-packages/spotdl/search/provider.py", line 478, in search_and_get_best_match
>     results = search_and_order_ytm_results(
>   File "/root/master/lib/python3.8/site-packages/spotdl/search/provider.py", line 366, in search_and_order_ytm_results
>     results = __query_and_simplify(songSearchStr)
>   File "/root/master/lib/python3.8/site-packages/spotdl/search/provider.py", line 176, in __query_and_simplify
>     linkBlock = contents['musicResponsiveListItemRenderer'] \
> KeyError: 'playNavigationEndpoint'
> Exception ignored in: <function tqdm.__del__ at 0x7f502d906820>
> Traceback (most recent call last):
>   File "/root/master/lib/python3.8/site-packages/tqdm/std.py", line 1124, in __del__
>   File "/root/master/lib/python3.8/site-packages/tqdm/std.py", line 1337, in close
>   File "/root/master/lib/python3.8/site-packages/tqdm/std.py", line 1516, in display
>   File "/root/master/lib/python3.8/site-packages/tqdm/std.py", line 1127, in __repr__
>   File "/root/master/lib/python3.8/site-packages/spotdl/download/progressHandlers.py", line 23, in format_dict
>   File "/root/master/lib/python3.8/site-packages/tqdm/std.py", line 1477, in format_dict
> TypeError: cannot unpack non-iterable NoneType object

Here is what I got when I add that block:

Fetching Playlist...                                                           
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 426, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 421, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.8/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/lib/python3.8/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.8/http/client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.8/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.8/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3.8/site-packages/urllib3/util/retry.py", line 403, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3.8/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 428, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 335, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.spotify.com', port=443): Read timed out. (read timeout=5)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lvlzyro/.local/bin/spotdl", line 8, in <module>
    sys.exit(console_entry_point())
  File "/home/lvlzyro/.local/lib/python3.8/site-packages/spotdl/__main__.py", line 114, in console_entry_point
    songObjList = get_playlist_tracks(request)
  File "/home/lvlzyro/.local/lib/python3.8/site-packages/spotdl/search/utils.py", line 82, in get_playlist_tracks
    song = SongObj.from_url(
  File "/home/lvlzyro/.local/lib/python3.8/site-packages/spotdl/search/songObj.py", line 41, in from_url
    rawTrackMeta = spotifyClient.track(spotifyURL)
  File "/home/lvlzyro/.local/lib/python3.8/site-packages/spotipy/client.py", line 338, in track
    return self._get("tracks/" + trid)
  File "/home/lvlzyro/.local/lib/python3.8/site-packages/spotipy/client.py", line 291, in _get
    return self._internal_call("GET", url, payload, kwargs)
  File "/home/lvlzyro/.local/lib/python3.8/site-packages/spotipy/client.py", line 240, in _internal_call
    response = self._session.request(
  File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.8/site-packages/requests/adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.spotify.com', port=443): Read timed out. (read timeout=5)