Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP 401 when downloading artist/album #2154

Closed
DeadLumina opened this issue Aug 10, 2024 · 4 comments
Closed

HTTP 401 when downloading artist/album #2154

DeadLumina opened this issue Aug 10, 2024 · 4 comments
Labels
Bug Unexpected problem or unintended behavior that needs to be fixed

Comments

@DeadLumina
Copy link

DeadLumina commented Aug 10, 2024

System OS

Linux

Python Version

3.12.4 (CPython)

Install Source

pip / PyPi

Install version / commit hash

4.2.5

Expected Behavior vs Actual Behavior

Expected: Download should start after querying artists / albums.
Actual: Most times an exception is thrown with error HTTP 401. After multiple attempts however it works.

Steps to reproduce - Ensure to include actual links!

  1. Start spotdl download https://open.spotify.com/artist/7HxWNbJlF1jfvUOej0aVPY?si=351f251c1c45498f(any artist/album/song will do)
  2. ???
  3. Sometimes it happens and other times it doesn't

Traceback

[06:08:40 PM] DEBUG    MainThread - Downloader settings: {'audio_providers': ['youtube-music', 'youtube', 'piped'], 'lyrics_providers': ['genius', 'musixmatch', 'azlyrics'], 'playlist_numbering': False, 'scan_for_songs': False, 'm3u': None, 'output': '{album-artist}/{album}/{artist} -              downloader.py:131
                       {title}.{output-ext}', 'overwrite': 'skip', 'search_query': None, 'ffmpeg': 'ffmpeg', 'bitrate': '0', 'ffmpeg_args': '-threads 24 -hide_banner -compression_level 0', 'format': 'mp3', 'save_file': '/home/me/.spotdl/save.spotdl', 'filter_results': True, 'album_type': None,                      
                       'threads': 7, 'cookie_file': '/home/me/.spotdl/cookies.txt', 'restrict': None, 'print_errors': False, 'sponsor_block': False, 'preload': False, 'archive': None, 'load_config': True, 'log_level': 'DEBUG', 'simple_tui': False, 'fetch_albums': False, 'id3_separator': '/',                        
                       'ytm_data': False, 'add_unavailable': False, 'generate_lrc': False, 'force_update_metadata': False, 'only_verified_results': False, 'sync_without_deleting': False, 'max_filename_length': None, 'yt_dlp_args': "--ignore-config -6 --no-part --extractor-args --extractor-args                      
                       'youtube:skip=translated_subs;player_client=web,ios,web_safari'", 'detect_formats': None, 'save_errors': None, 'ignore_albums': None, 'proxy': None, 'skip_explicit': False, 'log_format': None, 'redownload': False, 'skip_album_art': False, 'create_skip_file': False,                            
                       'respect_skip_file': False}                                                                                                                                                                                                                                                                          
[06:08:40 PM] DEBUG    MainThread - FFmpeg path: ffmpeg                                                                                                                                                                                                                                                    downloader.py:149
[06:08:40 PM] DEBUG    MainThread - Found 0 known songs                                                                                                                                                                                                                                                    downloader.py:184
[06:08:41 PM] DEBUG    MainThread - Archive: 0 urls                                                                                                                                                                                                                                                        downloader.py:231
[06:08:41 PM] DEBUG    MainThread - Downloader initialized                                                                                                                                                                                                                                                 downloader.py:233
[06:08:41 PM] INFO     MainThread - Processing query: https://open.spotify.com/artist/7HxWNbJlF1jfvUOej0aVPY?si=351f251c1c45498f                                                                                                                                                                               search.py:137
[06:08:43 PM] DEBUG    MainThread - Took 1 seconds                                                                                                                                                                                                                                                        entry_point.py:156
HTTP Error for GET to https://api.spotify.com/v1/albums/1yrKtItFzrZIQvjEOivCeg with Params: {} returned 401 due to None
[06:08:43 PM] ERROR    MainThread - An error occurred                                                                                                                                                                                                                                                     entry_point.py:159
                       ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮                   
                       │ /home/me/.local/lib/python3.12/site-packages/spotipy/client.py:275 in _internal_call                                                                                                                                                                                           │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │    272 │   │   │   │   timeout=self.requests_timeout, **args                                                                                                                                                                                                                   │                   
                       │    273 │   │   │   )                                                                                                                                                                                                                                                           │                   
                       │    274 │   │   │                                                                                                                                                                                                                                                               │                   
                       │ ❱  275 │   │   │   response.raise_for_status()                                                                                                                                                                                                                                 │                   
                       │    276 │   │   │   results = response.json()                                                                                                                                                                                                                                   │                   
                       │    277 │   │   except requests.exceptions.HTTPError as http_error:                                                                                                                                                                                                             │                   
                       │    278 │   │   │   response = http_error.response                                                                                                                                                                                                                              │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │ /home/me/.local/lib/python3.12/site-packages/requests/models.py:1024 in raise_for_status                                                                                                                                                                                       │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │   1021 │   │   │   )                                                                                                                                                                                                                                                           │                   
                       │   1022 │   │                                                                                                                                                                                                                                                                   │                   
                       │   1023 │   │   if http_error_msg:                                                                                                                                                                                                                                              │                   
                       │ ❱ 1024 │   │   │   raise HTTPError(http_error_msg, response=self)                                                                                                                                                                                                              │                   
                       │   1025 │                                                                                                                                                                                                                                                                       │                   
                       │   1026 │   def close(self):                                                                                                                                                                                                                                                    │                   
                       │   1027 │   │   """Releases the connection back to the pool. Once this method has been                                                                                                                                                                                          │                   
                       ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                   
                       HTTPError: 401 Client Error: Unauthorized for url: https://api.spotify.com/v1/albums/1yrKtItFzrZIQvjEOivCeg                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                            
                       During handling of the above exception, another exception occurred:                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                            
                       ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮                   
                       │ /home/me/.local/lib/python3.12/site-packages/spotdl/console/entry_point.py:142 in console_entry_point                                                                                                                                                                          │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │   139 │   try:                                                                                                                                                                                                                                                                 │                   
                       │   140 │   │   # Pick the operation to perform                                                                                                                                                                                                                                  │                   
                       │   141 │   │   # based on the name and run it!                                                                                                                                                                                                                                  │                   
                       │ ❱ 142 │   │   OPERATIONS[arguments.operation](                                                                                                                                                                                                                                 │                   
                       │   143 │   │   │   query=arguments.query,                                                                                                                                                                                                                                       │                   
                       │   144 │   │   │   downloader=downloader,                                                                                                                                                                                                                                       │                   
                       │   145 │   │   )                                                                                                                                                                                                                                                                │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │ /home/me/.local/lib/python3.12/site-packages/spotdl/console/download.py:25 in download                                                                                                                                                                                         │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │   22 │   """                                                                                                                                                                                                                                                                   │                   
                       │   23 │                                                                                                                                                                                                                                                                         │                   
                       │   24 │   # Parse the query                                                                                                                                                                                                                                                     │                   
                       │ ❱ 25 │   songs = get_simple_songs(                                                                                                                                                                                                                                             │                   
                       │   26 │   │   query,                                                                                                                                                                                                                                                            │                   
                       │   27 │   │   use_ytm_data=downloader.settings["ytm_data"],                                                                                                                                                                                                                     │                   
                       │   28 │   │   playlist_numbering=downloader.settings["playlist_numbering"],                                                                                                                                                                                                     │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │ /home/me/.local/lib/python3.12/site-packages/spotdl/utils/search.py:264 in get_simple_songs                                                                                                                                                                                    │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │   261 │   │   elif "open.spotify.com" in request and "album" in request:                                                                                                                                                                                                       │                   
                       │   262 │   │   │   lists.append(Album.from_url(request, fetch_songs=False))                                                                                                                                                                                                     │                   
                       │   263 │   │   elif "open.spotify.com" in request and "artist" in request:                                                                                                                                                                                                      │                   
                       │ ❱ 264 │   │   │   lists.append(Artist.from_url(request, fetch_songs=False))                                                                                                                                                                                                    │                   
                       │   265 │   │   elif "open.spotify.com" in request and "user" in request:                                                                                                                                                                                                        │                   
                       │   266 │   │   │   lists.extend(get_all_user_playlists(request))                                                                                                                                                                                                                │                   
                       │   267 │   │   elif "album:" in request:                                                                                                                                                                                                                                        │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │ /home/me/.local/lib/python3.12/site-packages/spotdl/types/song.py:306 in from_url                                                                                                                                                                                              │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │   303 │   │   - The SongList object.                                                                                                                                                                                                                                           │                   
                       │   304 │   │   """                                                                                                                                                                                                                                                              │                   
                       │   305 │   │                                                                                                                                                                                                                                                                    │                   
                       │ ❱ 306 │   │   metadata, songs = cls.get_metadata(url)                                                                                                                                                                                                                          │                   
                       │   307 │   │   urls = [song.url for song in songs]                                                                                                                                                                                                                              │                   
                       │   308 │   │                                                                                                                                                                                                                                                                    │                   
                       │   309 │   │   if fetch_songs:                                                                                                                                                                                                                                                  │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │ /home/me/.local/lib/python3.12/site-packages/spotdl/types/artist.py:87 in get_metadata                                                                                                                                                                                         │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │    84 │   │                                                                                                                                                                                                                                                                    │                   
                       │    85 │   │   songs = []                                                                                                                                                                                                                                                       │                   
                       │    86 │   │   for album in albums:                                                                                                                                                                                                                                             │                   
                       │ ❱  87 │   │   │   album_obj = Album.from_url(album, fetch_songs=False)                                                                                                                                                                                                         │                   
                       │    88 │   │   │   songs.extend(album_obj.songs)                                                                                                                                                                                                                                │                   
                       │    89 │   │                                                                                                                                                                                                                                                                    │                   
                       │    90 │   │   # Very aggressive deduplication                                                                                                                                                                                                                                  │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │ /home/me/.local/lib/python3.12/site-packages/spotdl/types/song.py:306 in from_url                                                                                                                                                                                              │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │   303 │   │   - The SongList object.                                                                                                                                                                                                                                           │                   
                       │   304 │   │   """                                                                                                                                                                                                                                                              │                   
                       │   305 │   │                                                                                                                                                                                                                                                                    │                   
                       │ ❱ 306 │   │   metadata, songs = cls.get_metadata(url)                                                                                                                                                                                                                          │                   
                       │   307 │   │   urls = [song.url for song in songs]                                                                                                                                                                                                                              │                   
                       │   308 │   │                                                                                                                                                                                                                                                                    │                   
                       │   309 │   │   if fetch_songs:                                                                                                                                                                                                                                                  │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │ /home/me/.local/lib/python3.12/site-packages/spotdl/types/album.py:42 in get_metadata                                                                                                                                                                                          │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │    39 │   │                                                                                                                                                                                                                                                                    │                   
                       │    40 │   │   spotify_client = SpotifyClient()                                                                                                                                                                                                                                 │                   
                       │    41 │   │                                                                                                                                                                                                                                                                    │                   
                       │ ❱  42 │   │   album_metadata = spotify_client.album(url)                                                                                                                                                                                                                       │                   
                       │    43 │   │   if album_metadata is None:                                                                                                                                                                                                                                       │                   
                       │    44 │   │   │   raise AlbumError(                                                                                                                                                                                                                                            │                   
                       │    45 │   │   │   │   "Couldn't get metadata, check if you have passed correct album id"                                                                                                                                                                                       │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │ /home/me/.local/lib/python3.12/site-packages/spotipy/client.py:476 in album                                                                                                                                                                                                    │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │    473 │   │   if market is not None:                                                                                                                                                                                                                                          │                   
                       │    474 │   │   │   return self._get("albums/" + trid + '?market=' + market)                                                                                                                                                                                                    │                   
                       │    475 │   │   else:                                                                                                                                                                                                                                                           │                   
                       │ ❱  476 │   │   │   return self._get("albums/" + trid)                                                                                                                                                                                                                          │                   
                       │    477 │                                                                                                                                                                                                                                                                       │                   
                       │    478 │   def album_tracks(self, album_id, limit=50, offset=0, market=None):                                                                                                                                                                                                  │                   
                       │    479 │   │   """ Get Spotify catalog information about an album's tracks                                                                                                                                                                                                     │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │ /home/me/.local/lib/python3.12/site-packages/spotdl/utils/spotify.py:195 in _get                                                                                                                                                                                               │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │   192 │   │   retries = self.max_retries  # type: ignore # pylint: disable=E1101                                                                                                                                                                                               │                   
                       │   193 │   │   while response is None:                                                                                                                                                                                                                                          │                   
                       │   194 │   │   │   try:                                                                                                                                                                                                                                                         │                   
                       │ ❱ 195 │   │   │   │   response = self._internal_call("GET", url, payload, kwargs)                                                                                                                                                                                              │                   
                       │   196 │   │   │   except (requests.exceptions.Timeout, requests.ConnectionError) as exc:                                                                                                                                                                                       │                   
                       │   197 │   │   │   │   retries -= 1                                                                                                                                                                                                                                             │                   
                       │   198 │   │   │   │   if retries <= 0:                                                                                                                                                                                                                                         │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │ /home/me/.local/lib/python3.12/site-packages/spotipy/client.py:297 in _internal_call                                                                                                                                                                                           │                   
                       │                                                                                                                                                                                                                                                                                │                   
                       │    294 │   │   │   │   method, url, args.get("params"), response.status_code, msg                                                                                                                                                                                              │                   
                       │    295 │   │   │   )                                                                                                                                                                                                                                                           │                   
                       │    296 │   │   │                                                                                                                                                                                                                                                               │                   
                       │ ❱  297 │   │   │   raise SpotifyException(                                                                                                                                                                                                                                     │                   
                       │    298 │   │   │   │   response.status_code,                                                                                                                                                                                                                                   │                   
                       │    299 │   │   │   │   -1,                                                                                                                                                                                                                                                     │                   
                       │    300 │   │   │   │   f"{response.url}:\n {msg}",                                                                                                                                                                                                                             │                   
                       ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                   
                       SpotifyException: http status: 401, code:-1 - https://api.spotify.com/v1/albums/1yrKtItFzrZIQvjEOivCeg:                                                                                                                                                                                              
                        None, reason: None

Other details

Raw JSON Response:

{
  "error": {
    "status": 401,
    "message": "No token provided"
  }
}

UPDATE as of 2024-08-18:

I have continued downloading large amounts of songs, and I haven't encountered the problem in a few days. Maybe a problem on Spotify's side?

@DeadLumina DeadLumina added the Bug Unexpected problem or unintended behavior that needs to be fixed label Aug 10, 2024
@DrMxrcy
Copy link

DrMxrcy commented Aug 11, 2024

Getting the same here on my end for some downloads

@guerda
Copy link

guerda commented Aug 12, 2024

I have the same issues with different playlists. Is it possible that the client ID is throttled?

@DrMxrcy
Copy link

DrMxrcy commented Aug 13, 2024

I have the same issues with different playlists. Is it possible that the client ID is throttled?

I have tried rotating between 3 Different Client IDs. I am not sure

@xnetcat
Copy link
Member

xnetcat commented Aug 19, 2024

I have tried rotating between 3 Different Client IDs. I am not sure

Either this or threre's an issue on the spotify's side

closing in favor of #2142

@xnetcat xnetcat closed this as not planned Won't fix, can't repro, duplicate, stale Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Unexpected problem or unintended behavior that needs to be fixed
Projects
None yet
Development

No branches or pull requests

4 participants