[GH-ISSUE #553] 'NoneType' has no attribute 'split' when trying to fetch audio features for a list of song ids #333

Closed
opened 2026-02-27 23:22:03 +03:00 by kerem · 4 comments
Owner

Originally created by @hanss0n on GitHub (Aug 9, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/553

Describe the bug
Fetching features for a list of song id's gives me a python error

Your code

credentials = SpotifyClientCredentials(
    client_id=client_id,
    client_secret=client_secret)

spotify = spotipy.Spotify(auth=credentials.get_access_token())

song_ids = ['7uZNffK8arChpeCVV6ooDr', '3ehKHnuLaIIOVhAtgUi5wD', '5mRDK6F8gJjt23LL3Iy3Hp', '34NNeV9jfgNgaALgUr0u9V', '1vQ92830bxiBcIhpUj4qrn', '53vJGKfm25KT22hXvCTU4I', '7EAM4KXX04XU9H0VwxtqyE', '2WIuQNRwLRuBJY9tkLMGpN', '4pk4W1VtvrQO3so7LGvtIl', '55jiDN7K7OtbBANR4vlTuQ', '4tztBBPjkqzxfPG8jQ1Rh5', '79FSutPOikJHaWscFTtymd', '6mCR84oWk19XCfGTCL9Wee', '0AhRPDuVwHkLAACbPXidb3', '40AYRnDKhhrH4JZO4KS9Dj', '4GWnDzLsP31cul3K88pKVn', '2YBnNbMOUUSkqncnQgkqST', '70siNXjjzwMZ3WHPSaPz0P', '13ZsIACMHaWi8F1va20QZW', '46GI18GhwT31iAZfgCR2gF', '4smUfRf4r4zIgvPW0W0ILN', '2GTi76fD1RgO34wDxRaeXB', '02aQOlXR3R2uQpatJqt7v3', '12KmwMaA5q76JdmFfE0uL9', '1Ag7wxTGvCK4Vqw5PPqdle', '3qC3qmZNDXu62hc8YbhWsy', '1t7ToVITrs0LkMwRC2XEON', '1GfZuvW3k5Ci52eNTgOkTw', '42U2KTNRv0KSDnkQNiQjbo', '5JUbrNZTDZu77uqy8R9GYy', '6A2TqxtIW1On4gXlCXTlKX', '68jajO3lJDSOsKSyXiEmJl', '5DMgHQS7W53azRdFnXHH6d', '137O1R5exWz3qxpq2Mtdib', '5j5xz0zpIfNcS1FZwOZo2i', '065mLOJfAqeHZ162rIx5YB', '4Pb7Mg18H4S0jCGgH6bIIq', '5QyEPCvvT2Qmded0BZ7GGG', '7MKYNJAjqIRkW9S71GSwAJ', '2NBrtRd7wE6JYLPbnHkTOO', '0FvYOpdqf3hO9pK88716uh', '6JoxpsF0yzjRcZyrPJPfXY', '29zZGZm12irXsA1mf2rlGo', '3aXM9duTbQJDnNrOzh8cb6', '3SihC64kvAsvnBPyDgMW3y', '00Tdk7uw0KudbIrdg0niLi', '62vHkhd3HgdzLHmkgwsxzZ', '4BBzCCib0j9qMneACP7HeE', None, '6g1NlCpW7fgqDnWbCCDrHl', '1A29M5wR1kbCuzc9CTeU6y', '7xMoXPnN5PwXFfvhynj02P', '2pMSrjYVTUP2qyUBj6OFhj', '1hPYVFjQ3Dgv1PK3NytIIb', '5YHmAO5OSZqyvs0X9O3hEK', '45HrXgH40Jbq6bxh165aI1', '3FE6Xwjn3z8W3wlhIgpFUD', '3ljB23GWqz8h5c4rAIUkL2', '2an7yYoSs5T3AFO0TFHohj', '1oetTjzloPtOPMSQmw6EP3', '1OIap2AeiVhAavWyRKTSba', '2W0p4sfCxY6fUXS3y01hVw', '2b3nvCZ4dwBfAvDWWIG4H8', '3JV8mp0SJ7YmSeYjE8NMLZ', '6vOCcO3YjdfaXkaFpcMtPz', '5ZwTAZe3enscONgoMKTd9Y', '21ycThF1ruVSPyaw8BkRHM', '5RsbvJQ6q82oc9hyaLEmmV', '3L2W7SDk3beBYEfOBblWCG', '5bw3ANysdLNdRl8wZfunVp', '5fDydQ2X61CcVtt48UXMNb', '1fjCRAIaEABA1bQzgYYtpd', '0HuJhVu0fMc26n8kcPwVTc', '6PUIzlqotEmPuBfjbwYWOB', '2oKPjUNx0kAj9JlPABZFxw', '3bzqd8quMDaCt7pLb98SHS', '4dWuPULnSVkzJC0wDFlAxS', '0gIZXqW6s7zSf21bFrzI29', '13gD7RyWE7ZOEoxfGAXm1B', '352zfYbDFG8sxkmOAhVeuj', '5Khth2Cb94VH6O1T4K0lqK', '3QEoWceTh3j9dCJHwmuSj1', '5SMYN4lHZduUD8SQ0TEHj2', '7nkOH6CQX02HDuXKWYuh1I', '6UUhruYdm0bgynD8ERUHmL', '7jX4E7JPe9CqLexMobIWNY', '6GVtybBya8EzI4rC9P7FQM', '2N2Mp4HjnYcmrZ2YqrKedy', '4tQMd2go7qhp914CTHKdql', '2B8eAzF1rlTOLynq5zgXsG', '1nsvulFIVKrfPMM0592qCe', '0O3ejIM41qOAxJBizTEADf', '1sqN9hAFDFYMzTE1JLhPaS', '58KRLZxN7H9ZYoMyWiWAj6', '3g1yJqVEx6FKlUzy2GL6Id', '2emXGZyrkTEfy383K3hDhG', '6UEJtAnGHnK5tVhoPHD6tU', '4IWLawtdMznqdOnbOR9cWW', '0R7gbDisCJLii7ByE2rHJh', '0XtDMRff7VOvKQYedTUHKt']

features = spotify.audio_features(song_ids)

Expected behavior
I expected to get the features for the song id's I queried

Output

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/spotipy/client.py", line 1248, in audio_features
tlist = [self._get_id("track", t) for t in tracks]
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/spotipy/client.py", line 1248, in
tlist = [self._get_id("track", t) for t in tracks]
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/spotipy/client.py", line 1467, in _get_id
fields = id.split(":")
AttributeError: 'NoneType' object has no attribute 'split'

Environment:

  • OS: Mac
  • Python version: 3.8
  • spotipy version: 2.13
  • your IDE: PyCharm

Additional informaton:
This worked perfectly fine for me previously, so I'm wondering if anything happened with Spotify's web api?

EDIT:
I have managed to figure out that this only happens on some of my playlists, for example the id's in the following playlist:
spotify:playlist:5YtuU88z2sdmp0yfuJWytn (the one posted above)

Originally created by @hanss0n on GitHub (Aug 9, 2020). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/553 **Describe the bug** Fetching features for a list of song id's gives me a python error **Your code** ```Python credentials = SpotifyClientCredentials( client_id=client_id, client_secret=client_secret) spotify = spotipy.Spotify(auth=credentials.get_access_token()) song_ids = ['7uZNffK8arChpeCVV6ooDr', '3ehKHnuLaIIOVhAtgUi5wD', '5mRDK6F8gJjt23LL3Iy3Hp', '34NNeV9jfgNgaALgUr0u9V', '1vQ92830bxiBcIhpUj4qrn', '53vJGKfm25KT22hXvCTU4I', '7EAM4KXX04XU9H0VwxtqyE', '2WIuQNRwLRuBJY9tkLMGpN', '4pk4W1VtvrQO3so7LGvtIl', '55jiDN7K7OtbBANR4vlTuQ', '4tztBBPjkqzxfPG8jQ1Rh5', '79FSutPOikJHaWscFTtymd', '6mCR84oWk19XCfGTCL9Wee', '0AhRPDuVwHkLAACbPXidb3', '40AYRnDKhhrH4JZO4KS9Dj', '4GWnDzLsP31cul3K88pKVn', '2YBnNbMOUUSkqncnQgkqST', '70siNXjjzwMZ3WHPSaPz0P', '13ZsIACMHaWi8F1va20QZW', '46GI18GhwT31iAZfgCR2gF', '4smUfRf4r4zIgvPW0W0ILN', '2GTi76fD1RgO34wDxRaeXB', '02aQOlXR3R2uQpatJqt7v3', '12KmwMaA5q76JdmFfE0uL9', '1Ag7wxTGvCK4Vqw5PPqdle', '3qC3qmZNDXu62hc8YbhWsy', '1t7ToVITrs0LkMwRC2XEON', '1GfZuvW3k5Ci52eNTgOkTw', '42U2KTNRv0KSDnkQNiQjbo', '5JUbrNZTDZu77uqy8R9GYy', '6A2TqxtIW1On4gXlCXTlKX', '68jajO3lJDSOsKSyXiEmJl', '5DMgHQS7W53azRdFnXHH6d', '137O1R5exWz3qxpq2Mtdib', '5j5xz0zpIfNcS1FZwOZo2i', '065mLOJfAqeHZ162rIx5YB', '4Pb7Mg18H4S0jCGgH6bIIq', '5QyEPCvvT2Qmded0BZ7GGG', '7MKYNJAjqIRkW9S71GSwAJ', '2NBrtRd7wE6JYLPbnHkTOO', '0FvYOpdqf3hO9pK88716uh', '6JoxpsF0yzjRcZyrPJPfXY', '29zZGZm12irXsA1mf2rlGo', '3aXM9duTbQJDnNrOzh8cb6', '3SihC64kvAsvnBPyDgMW3y', '00Tdk7uw0KudbIrdg0niLi', '62vHkhd3HgdzLHmkgwsxzZ', '4BBzCCib0j9qMneACP7HeE', None, '6g1NlCpW7fgqDnWbCCDrHl', '1A29M5wR1kbCuzc9CTeU6y', '7xMoXPnN5PwXFfvhynj02P', '2pMSrjYVTUP2qyUBj6OFhj', '1hPYVFjQ3Dgv1PK3NytIIb', '5YHmAO5OSZqyvs0X9O3hEK', '45HrXgH40Jbq6bxh165aI1', '3FE6Xwjn3z8W3wlhIgpFUD', '3ljB23GWqz8h5c4rAIUkL2', '2an7yYoSs5T3AFO0TFHohj', '1oetTjzloPtOPMSQmw6EP3', '1OIap2AeiVhAavWyRKTSba', '2W0p4sfCxY6fUXS3y01hVw', '2b3nvCZ4dwBfAvDWWIG4H8', '3JV8mp0SJ7YmSeYjE8NMLZ', '6vOCcO3YjdfaXkaFpcMtPz', '5ZwTAZe3enscONgoMKTd9Y', '21ycThF1ruVSPyaw8BkRHM', '5RsbvJQ6q82oc9hyaLEmmV', '3L2W7SDk3beBYEfOBblWCG', '5bw3ANysdLNdRl8wZfunVp', '5fDydQ2X61CcVtt48UXMNb', '1fjCRAIaEABA1bQzgYYtpd', '0HuJhVu0fMc26n8kcPwVTc', '6PUIzlqotEmPuBfjbwYWOB', '2oKPjUNx0kAj9JlPABZFxw', '3bzqd8quMDaCt7pLb98SHS', '4dWuPULnSVkzJC0wDFlAxS', '0gIZXqW6s7zSf21bFrzI29', '13gD7RyWE7ZOEoxfGAXm1B', '352zfYbDFG8sxkmOAhVeuj', '5Khth2Cb94VH6O1T4K0lqK', '3QEoWceTh3j9dCJHwmuSj1', '5SMYN4lHZduUD8SQ0TEHj2', '7nkOH6CQX02HDuXKWYuh1I', '6UUhruYdm0bgynD8ERUHmL', '7jX4E7JPe9CqLexMobIWNY', '6GVtybBya8EzI4rC9P7FQM', '2N2Mp4HjnYcmrZ2YqrKedy', '4tQMd2go7qhp914CTHKdql', '2B8eAzF1rlTOLynq5zgXsG', '1nsvulFIVKrfPMM0592qCe', '0O3ejIM41qOAxJBizTEADf', '1sqN9hAFDFYMzTE1JLhPaS', '58KRLZxN7H9ZYoMyWiWAj6', '3g1yJqVEx6FKlUzy2GL6Id', '2emXGZyrkTEfy383K3hDhG', '6UEJtAnGHnK5tVhoPHD6tU', '4IWLawtdMznqdOnbOR9cWW', '0R7gbDisCJLii7ByE2rHJh', '0XtDMRff7VOvKQYedTUHKt'] features = spotify.audio_features(song_ids) ``` **Expected behavior** I expected to get the features for the song id's I queried **Output** > File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/spotipy/client.py", line 1248, in audio_features tlist = [self._get_id("track", t) for t in tracks] File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/spotipy/client.py", line 1248, in <listcomp> tlist = [self._get_id("track", t) for t in tracks] File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/spotipy/client.py", line 1467, in _get_id fields = id.split(":") AttributeError: 'NoneType' object has no attribute 'split' **Environment:** - OS: Mac - Python version: 3.8 - spotipy version: 2.13 - your IDE: PyCharm **Additional informaton:** This worked perfectly fine for me previously, so I'm wondering if anything happened with Spotify's web api? **EDIT:** I have managed to figure out that this only happens on some of my playlists, for example the id's in the following playlist: spotify:playlist:5YtuU88z2sdmp0yfuJWytn (the one posted above)
kerem 2026-02-27 23:22:03 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@stephanebruckert commented on GitHub (Aug 10, 2020):

One of your IDs is None

<!-- gh-comment-id:671222459 --> @stephanebruckert commented on GitHub (Aug 10, 2020): One of your IDs is `None`
Author
Owner

@hanss0n commented on GitHub (Aug 10, 2020):

Good catch, but why is one of the songs id's None after calling playlist_tracks('spotify:playlist:5YtuU88z2sdmp0yfuJWytn', fields='items.track.id')?

<!-- gh-comment-id:671224632 --> @hanss0n commented on GitHub (Aug 10, 2020): Good catch, but why is one of the songs id's None after calling `playlist_tracks('spotify:playlist:5YtuU88z2sdmp0yfuJWytn', fields='items.track.id')`?
Author
Owner

@stephanebruckert commented on GitHub (Aug 10, 2020):

    {
      "track": {
        "album": {
          "album_type": null,
          "artists": [],
          "available_markets": [],
          "external_urls": {},
          "href": null,
          "id": null,
          "images": [],
          "name": "",
          "release_date": null,
          "release_date_precision": null,
          "type": "album",
          "uri": null
        },
        "artists": [
          {
            "external_urls": {},
            "href": null,
            "id": null,
            "name": "",
            "type": "artist",
            "uri": null
          }
        ],
        "available_markets": [],
        "disc_number": 0,
        "duration_ms": 322000,
        "explicit": false,
        "external_ids": {},
        "external_urls": {},
        "href": null,
        "id": null,
        "is_local": true,
        "name": "[■ ▶ ▮▮] Ў Osen & Baha - The Warrior (Lush & Simon Remix) ★  EXCLUSIVE! for club5485048 ★ [track at ➨ 07.10.2013] - Progressive House",
        "popularity": 0,
        "preview_url": null,
        "track_number": 0,
        "type": "track",
        "uri": "spotify:local:::%5B%E2%96%A0+%E2%96%B6+%E2%96%AE%E2%96%AE%5D+%D0%8E+Osen+%26+Baha+-+The+Warrior+%28Lush+%26+Simon+Remix%29+%E2%98%85++EXCLUSIVE%21+for+club5485048+%E2%98%85+%5Btrack+at+%E2%9E%A8+07.10.2013%5D+-+Progressive+House:322"
      }
    }

It looks like it is a local track and being unknown to spotify, doesn't have an id

"uri": "spotify:local:::%5B%E2%96%A0+%E2%96%B6+%E2%96%AE%E2%96%AE%5D+%D0%8E+Osen+%26+Baha+-+The+Warrior+%28Lush+%26+Simon+Remix%29+%E2%98%85++EXCLUSIVE%21+for+club5485048+%E2%98%85+%5Btrack+at+%E2%9E%A8+07.10.2013%5D+-+Progressive+House:322"
<!-- gh-comment-id:671253380 --> @stephanebruckert commented on GitHub (Aug 10, 2020): ``` { "track": { "album": { "album_type": null, "artists": [], "available_markets": [], "external_urls": {}, "href": null, "id": null, "images": [], "name": "", "release_date": null, "release_date_precision": null, "type": "album", "uri": null }, "artists": [ { "external_urls": {}, "href": null, "id": null, "name": "", "type": "artist", "uri": null } ], "available_markets": [], "disc_number": 0, "duration_ms": 322000, "explicit": false, "external_ids": {}, "external_urls": {}, "href": null, "id": null, "is_local": true, "name": "[■ ▶ ▮▮] Ў Osen & Baha - The Warrior (Lush & Simon Remix) ★ EXCLUSIVE! for club5485048 ★ [track at ➨ 07.10.2013] - Progressive House", "popularity": 0, "preview_url": null, "track_number": 0, "type": "track", "uri": "spotify:local:::%5B%E2%96%A0+%E2%96%B6+%E2%96%AE%E2%96%AE%5D+%D0%8E+Osen+%26+Baha+-+The+Warrior+%28Lush+%26+Simon+Remix%29+%E2%98%85++EXCLUSIVE%21+for+club5485048+%E2%98%85+%5Btrack+at+%E2%9E%A8+07.10.2013%5D+-+Progressive+House:322" } } ``` It looks like it is a local track and being unknown to spotify, doesn't have an id "uri": "spotify:local:::%5B%E2%96%A0+%E2%96%B6+%E2%96%AE%E2%96%AE%5D+%D0%8E+Osen+%26+Baha+-+The+Warrior+%28Lush+%26+Simon+Remix%29+%E2%98%85++EXCLUSIVE%21+for+club5485048+%E2%98%85+%5Btrack+at+%E2%9E%A8+07.10.2013%5D+-+Progressive+House:322"
Author
Owner

@hanss0n commented on GitHub (Aug 10, 2020):

Ah, that explains it. Thanks!

<!-- gh-comment-id:671337957 --> @hanss0n commented on GitHub (Aug 10, 2020): Ah, that explains it. Thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#333
No description provided.