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

TypeError on using SpotDL to downlaod playlists #1147

Closed
kyleharte opened this issue Jan 24, 2021 · 15 comments
Closed

TypeError on using SpotDL to downlaod playlists #1147

kyleharte opened this issue Jan 24, 2021 · 15 comments
Assignees
Labels
Bug Unexpected problem or unintended behavior that needs to be fixed

Comments

@kyleharte
Copy link

kyleharte commented Jan 24, 2021

Environment

  • System OS: Windows Subsystem for Linux 2
    Windows Subsystem for Linux 2
  • Python Version: Python 3.8.5
  • Install Source: pip3 install spotdl
  • Version OR Commit hash: 3.3.1

Expected Behaviour

Iterate over the playlist finding the songs

Actual Behaviour

Gets far down the list then throws a TyperError; 'NoneType' object is not subscriptable

Steps to Reproduce

1.spotdl https://open.spotify.com/playlist/6uMtvyRWTsOSLjRa5JXeRV?si=lSJgpT_mSrm2nz-I0614BA


Traceback

  File "/home/x/.local/bin/spotdl", line 8, in <module>
    sys.exit(console_entry_point())
  File "/home/x/.local/lib/python3.8/site-packages/spotdl/__main__.py", line 110, in console_entry_point
    songObjList = get_playlist_tracks(request)
  File "/home/x/.local/lib/python3.8/site-packages/spotdl/search/utils.py", line 83, in get_playlist_tracks
    'https://open.spotify.com/track/' + songEntry['track']['id'])
TypeError: 'NoneType' object is not subscriptable
Exception ignored in: <function tqdm.__del__ at 0x7f7b4c1de550>
Traceback (most recent call last):
  File "/home/x/.local/lib/python3.8/site-packages/tqdm/std.py", line 1134, in __del__
  File "/home/x/.local/lib/python3.8/site-packages/tqdm/std.py", line 1281, in close
  File "/home/x/.local/lib/python3.8/site-packages/tqdm/std.py", line 1467, in display
  File "/home/x/.local/lib/python3.8/site-packages/tqdm/std.py", line 1137, in __repr__
  File "/home/x/.local/lib/python3.8/site-packages/spotdl/download/progressHandlers.py", line 23, in format_dict
  File "/home/x/.local/lib/python3.8/site-packages/tqdm/std.py", line 1424, in format_dict
TypeError: cannot unpack non-iterable NoneType object

Any other information:

@kyleharte kyleharte added the Bug Unexpected problem or unintended behavior that needs to be fixed label Jan 24, 2021
@bee395
Copy link
Contributor

bee395 commented Jan 24, 2021

It looks like the track object of songObject of Taylor Swift - Love Story, but I don't know how that's possible.
I'm also unable to find the song in the playlist on Spotify.
{'added_at': '2020-01-22T08:43:17Z', 'added_by': {'external_urls': {'spotify': 'https://open.spotify.com/user/pm5gmrz0rm7b3eayz8aa51840'}, 'href': 'https://api.spotify.com/v1/users/pm5gmrz0rm7b3eayz8aa51840', 'id': 'pm5gmrz0rm7b3eayz8aa51840', 'type': 'user', 'uri': 'spotify:user:pm5gmrz0rm7b3eayz8aa51840'}, 'is_local': False, 'primary_color': None, 'track': None, 'video_thumbnail': None}

@bee395
Copy link
Contributor

bee395 commented Jan 25, 2021

I found the song it's the 357 entry in the list.
I don't see anything particular with the song, but the Spotify Python API is unable to retrieve any information about the song.

@kyleharte
Copy link
Author

Thats very weird that it would happening. I haven't looked at the code base yet but would surrounding it in a try catch statement help

@ghost
Copy link

ghost commented Jan 26, 2021

This is the same thing that happens when we stop filtering the ytm results of I'm not wrong.

cc:@s1as3r

@s1as3r
Copy link
Contributor

s1as3r commented Jan 26, 2021

I think we should compare songEntry with None before subscripting it.

Try adding this before line 82 in utils.py

if songEntry is None: 
    continue

@s1as3r
Copy link
Contributor

s1as3r commented Jan 26, 2021

This is the same thing that happens when we stop filtering the ytm results of I'm not wrong.

cc:@s1as3r

Yes, The error raised is the same one. Because when we don't filter out songs, some of the results don't have keys like 'videoId' in them.
But here, the cause is the spotify API and not ytmapi.

@s1as3r
Copy link
Contributor

s1as3r commented Jan 26, 2021

@kyleharte could you check if all the songs in that playlist are available in your country?

@kyleharte
Copy link
Author

It's my playlist, so it definitely would be.

@s1as3r
Copy link
Contributor

s1as3r commented Jan 26, 2021

I think we should compare songEntry with None before subscripting it.

Try adding this before line 82 in utils.py

if songEntry is None: 
    continue

Could you try this?

@bee395
Copy link
Contributor

bee395 commented Jan 27, 2021

Ah my bad. It's not the song Love Story that's the problem. But the song after that.
It looks like there is a song in between Love Story and Say Na Na Na, which also is not shown on the Spotify Website.

I found a similar issue on spotify/spotipy (See: spotipy-dev/spotipy#626)

@kyleharte you can skip any missing tracks by inserting this if statement on line 82 of utils.py, until it's fixed.

if songEntry['track'] is None:
    continue

@ghost
Copy link

ghost commented Jan 30, 2021

Hey @bee395, could you open a PR to hotfix with that change please

@bee395
Copy link
Contributor

bee395 commented Jan 30, 2021

Hey @bee395, could you open a PR to hotfix with that change please

I created a pull request.

@JavaScythe
Copy link

I also get this error when downloading any song.
Running on repl.it, is that the problem?

@Silverarmor
Copy link
Member

@JavaScythe This specific issue is resolved on v3.2.2.
However, repl.it does not support FFmpeg, so you cannot use spotDL there.

@xnetcat
Copy link
Member

xnetcat commented Mar 11, 2021

Fixed in v3.3.2

@xnetcat xnetcat closed this as completed Mar 11, 2021
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

6 participants