glomatico / spotify-web-downloader

A Python CLI app for downloading songs and music videos directly from Spotify.
443 stars 54 forks source link

Error 403 on Song Download Despite Correct Setup and Premium Account #80

Closed youngoris closed 1 month ago

youngoris commented 1 month ago

I've been experiencing an issue where the download process fails with a 403 Client Error: Forbidden. This happens when attempting to download a track using a premium account setup. The error seems to be associated with the Widevine licensing step.

{
    "wait_interval": 10,
    "download_music_video": false,
    "force_premium": true,
    "save_cover": false,
    "overwrite": false,
    "save_playlist": false,
    "lrc_only": false,
    "no_lrc": false,
    "log_level": "INFO",
    "print_exceptions": true,
    "cookies_path": "./Cookies/spotify.com_cookies.txt",
    "output_path": "./Music/Spotify_Web_Downloads",
    "temp_path": "temp",
    "wvd_path": "./.spotify-web-downloader/device.wvd",
    "ffmpeg_path": "ffmpeg",
    "mp4box_path": "MP4Box",
    "mp4decrypt_path": "mp4decrypt",
    "aria2c_path": "aria2c",
    "nm3u8dlre_path": "N_m3u8DL-RE",
    "remux_mode": "ffmpeg",
    "template_folder_album": "{album_artist}/{album}",
    "template_folder_compilation": "Compilations/{album}",
    "template_file_single_disc": "{track:02d} {title}",
    "template_file_multi_disc": "{disc}-{track:02d} {title}",
    "template_folder_no_album": "{artist}/Unknown Album",
    "template_file_no_album": "{title}",
    "template_file_playlist": "Playlists/{playlist_artist}/{playlist_title}",
    "date_tag_template": "%Y-%m-%dT%H:%M:%SZ",
    "exclude_tags": null,
    "truncate": null,
    "download_mode_song": "ytdlp",
    "premium_quality": true,
    "download_mode_video": "ytdlp"
}
A@iMac ~ % spotify-web-downloader 'https://open.spotify.com/track/0vg4WnUWvze6pBOJDTq99k?si=10278186611d48cf'
[INFO     15:19:15] (URL 1/1) Checking "https://open.spotify.com/track/0vg4WnUWvze6pBOJDTq99k?si=10278186611d48cf"
[INFO     15:19:15] (Track 1/1 from URL 1/1) Downloading "You're Beautiful"
[ERROR    15:19:18] (Track 1/1 from URL 1/1) Failed to download "You're Beautiful"
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/spotify_web_downloader/utils.py", line 8, in check_response
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://gue1-spclient.spotify.com/widevine-license/v1/audio/license

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/spotify_web_downloader/cli.py", line 518, in main
    decryption_key = downloader_song.get_decryption_key(pssh)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/spotify_web_downloader/downloader_song.py", line 35, in get_decryption_key
    license = self.downloader.spotify_api.get_widevine_license_music(challenge)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/spotify_web_downloader/spotify_api.py", line 128, in get_widevine_license_music
    check_response(response)
  File "/usr/local/lib/python3.11/site-packages/spotify_web_downloader/utils.py", line 10, in check_response
    _raise_response_exception(response)
  File "/usr/local/lib/python3.11/site-packages/spotify_web_downloader/utils.py", line 14, in _raise_response_exception
    raise Exception(
Exception: Request failed with status code 403: 
[INFO     15:19:18] Done (1 error(s))A@heyonggngdeiMac ~ % spotify-web-downloader 'https://open.spotify.com/track/0vg4WnUWvze6pBOJDTq99k?si=10278186611d48cf'
[INFO     15:19:15] (URL 1/1) Checking "https://open.spotify.com/track/0vg4WnUWvze6pBOJDTq99k?si=10278186611d48cf"
[INFO     15:19:15] (Track 1/1 from URL 1/1) Downloading "You're Beautiful"
[ERROR    15:19:18] (Track 1/1 from URL 1/1) Failed to download "You're Beautiful"
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/spotify_web_downloader/utils.py", line 8, in check_response
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://gue1-spclient.spotify.com/widevine-license/v1/audio/license

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/spotify_web_downloader/cli.py", line 518, in main
    decryption_key = downloader_song.get_decryption_key(pssh)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/spotify_web_downloader/downloader_song.py", line 35, in get_decryption_key
    license = self.downloader.spotify_api.get_widevine_license_music(challenge)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/spotify_web_downloader/spotify_api.py", line 128, in get_widevine_license_music
    check_response(response)
  File "/usr/local/lib/python3.11/site-packages/spotify_web_downloader/utils.py", line 10, in check_response
    _raise_response_exception(response)
  File "/usr/local/lib/python3.11/site-packages/spotify_web_downloader/utils.py", line 14, in _raise_response_exception
    raise Exception(
Exception: Request failed with status code 403: 
[INFO     15:19:18] Done (1 error(s))

Environment:

Configuration:

This error persists even after verifying all configurations and setups mentioned in the documentation. Could you please help me understand if there's a known issue with the Widevine licensing? Thank you!

alany08 commented 1 month ago

Same issue

downloader version: 1.8 OS: EndeavorOS Python: 3.12

Configuration:

The downloader fails immediately after "Getting decryption key"

Edit: struggles in markdown

glomatico commented 1 month ago

Try getting the .wvd from a different device/Android version.