couldbejake / spotify2mp3

Simple free and unlimited Spotify playlist downloads. Spotify2mp3 - Spotify Downloader
MIT License
269 stars 42 forks source link

Index out of bounds error due to missing album cover #38

Closed Unchain1014 closed 11 months ago

Unchain1014 commented 11 months ago

First of all thank you very much for such an amazing tool, it has been a great help in preserving my collection. I copied all my library into 100 song playlists for downloading, in order to stop using Spotify. Cheers.

Two of my songs are missing album art on Spotify, I'm not sure how that happened. I assume it broke some terms and so was removed by Spotify (because I know it is a requirement of submission). In any case, this caused a null exception which was easy enough to identify and remedy. Here is the exception for reference:

Traceback (most recent call last): File "/home/anon/spotify2mp3/spotify2mp3.py", line 164, in main(playlist=url, quality=quality, min_views=DEFAULT_MIN_VIEWS_FOR_DOWNLOAD, max_length=DEFAULT_MAX_LENGTH_FOR_DOWNLOAD) File "/home/anon/spotify2mp3/spotify2mp3.py", line 110, in main success =downloader.download_playlist(playlist)
File "/home/anon/spotify2mp3/downloader.py", line 75, in download_playlist self.prep_folder("downloads/playlists/" + playlist.get_title(True)) File "/home/anon/spotify2mp3/apis/spotify.py", line 133, in get_title self.load_metadata() File "/home/anon/spotify2mp3/apis/spotify.py", line 113, in load_metadata this_track.load_metadata(track["track"]) File "/home/anon/spotify2mp3/apis/spotify.py", line 304, in load_metadata "image_url": album_images[0].get("url", const.UNKNOWN_ALBUM_COVER_URL), IndexError: list index out of range

couldbejake commented 11 months ago

Hi, not a problem I will update the code for you now

It looks like album_images has no child elements, we can instead ensure album_images exists and has items, else use const.UNKNOWN_ALBUM_COVER_URL, a question mark image.

couldbejake commented 11 months ago

Do you happen to have the song the program failed on?

Unchain1014 commented 11 months ago

It was "March of Death" by OBNX

couldbejake commented 11 months ago

The application has now been updated. The faulty check for an album cover should now be patched.

Please let me know if you experience any more issues.

Kind regards, Jake!