spotDL / spotify-downloader

Download your Spotify playlists and songs along with album art and metadata (from YouTube if a match is found).
https://spotdl.readthedocs.io/en/latest/
MIT License
15.96k stars 1.51k forks source link

"IndexError: list index out of range" in get_album_cover_url #1229

Closed darklenre closed 3 years ago

darklenre commented 3 years ago

Environment


Expected Behaviour

Download all the songs of a playlist

Actual Behaviour

After downloading some songs Spotdl crashes throwing the error:

get_album_cover_url
    return self.__rawTrackMeta['album']['images'][0]['url']
IndexError: list index out of range

Steps to Reproduce

  1. Use a playlist URL as the input argument

Traceback


  Traceback (most recent call last):
  File "c:\users\user\appdata\local\programs\python\python38\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\user\appdata\local\programs\python\python38\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\Scripts\spotdl.exe\__main__.py", line 7, in <module>
  File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\spotdl\__main__.py", line 128, in console_entry_point
    downloader.download_multiple_songs(songObjList)
  File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\spotdl\download\downloader.py", line 86, in download_multiple_songs
    self._download_asynchronously(songObjList)
  File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\spotdl\download\downloader.py", line 364, in _download_asynchronously
    self.loop.run_until_complete(asyncio.gather(*tasks))
  File "c:\users\user\appdata\local\programs\python\python38\lib\asyncio\base_events.py", line 612, in run_until_complete
    return future.result()
  File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\spotdl\download\downloader.py", line 359, in _pool_download
    return await self.download_song(song_obj)
  File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\spotdl\download\downloader.py", line 248, in download_song
    self.set_id3_data(convertedFilePath, songObj)
  File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\spotdl\download\downloader.py", line 295, in set_id3_data
    rawAlbumArt = urlopen(songObj.get_album_cover_url()).read()
  File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\spotdl\search\songObj.py", line 215, in get_album_cover_url
    return self.__rawTrackMeta['album']['images'][0]['url']
IndexError: list index out of range

Any other information:

Silverarmor commented 3 years ago

Playlist link please

darklenre commented 3 years ago

https://open.spotify.com/playlist/1ZEKBfAjNoYa6trH1IDreT?si=517822ffa00a4aee It's a pretty big playlist.

I temporarily solved the issue by adding a check for the url before the return inside the get_album_cover_url() function and not inserting the rawAlbumArt in set_id3_data() if no url is returned

Songs that came out without AlbumArt: Camel - Mystic Queen daigoro789 - Rue des Cascades (Full Version) Deep Purple - Child in Time - 1995 Remaster Grandaddy - He's Simple, He's Dumb, He's The Pilot

Edit: added songs w/o AlbumArt

Silverarmor commented 3 years ago

Reproducible via spotdl https://open.spotify.com/track/02ZfVcdowfzkbSD5dKf2jA?si=iy0VtROpTbOd4ty4Lc4lEA

AZMCode commented 3 years ago

It appears the original song is gone from spotify, leaving only a live version, that's why there's no album cover

xnetcat commented 3 years ago

@AZMCode is correct original song is no longer available. Other songs download fine for me. If you are still having issues feel free to reopen this issue