glomatico / spotify-web-downloader

A Python CLI app for downloading songs/music videos/albums/playlists directly from Spotify.
378 stars 43 forks source link

Error when trying to download one track #9

Closed smirnovv2007 closed 3 months ago

smirnovv2007 commented 10 months ago

Track: https://open.spotify.com/track/1pXvHzvQ1sUHIwvN50wJWp Error:

Traceback (most recent call last):
  File "C:\Users\smirn\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Users\smirn\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Users\smirn\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\smirn\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\smirn\AppData\Local\Programs\Python\Python39\lib\site-packages\spotify_aac_downloader\cli.py", line 273, in main
    pssh = dl.get_pssh(file_id)
  File "C:\Users\smirn\AppData\Local\Programs\Python\Python39\lib\site-packages\spotify_aac_downloader\dl.py", line 158, in get_pssh
    return self.session.get(
  File "C:\Users\smirn\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
smirnovv2007 commented 10 months ago

Replacing get_pssh function's code to:

    def get_pssh(self, file_id):
        pssh_json = json.loads(self.session.get(f"https://seektables.scdn.co/seektable/{file_id}.json").text)
        return pssh_json["pssh"]

fixed this issue