glomatico / spotify-web-downloader

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

Program crashes when track metadata is not found #39

Closed Shrey-Varma closed 3 months ago

Shrey-Varma commented 3 months ago

Error:

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/spotify_web_downloader/cli.py", line 361, in main
    logger.info(f'({queue_progress}) Downloading "{track["name"]}"')
                                                   ~~~~~^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/bin/spotify-web-downloader", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/spotify_web_downloader/cli.py", line 556, in main
    f'({queue_progress}) Failed to download "{track["name"]}"',
                                              ~~~~~^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Possible fix to check if track is None within the main function after initializing track:

track = queue_item.metadata
if track is None:
    logger.warning(f'({queue_progress}) No track information available for download.')
    continue
glomatico commented 3 months ago

Link to this track?