[GH-ISSUE #731] playlist_tracks field market still prints regions when set to None #440

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

Originally created by @Neopect on GitHub (Sep 24, 2021).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/731

Describe the bug
When I use any of the playlist functions to fetch the contents of the playlist it returns the available_markets field regardless of setting market=None.

Your code

from spotipy.oauth2 import SpotifyClientCredentials
import spotipy
import json

sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials(client_id="clientID",
                                                           client_secret="secret"))

playlist_id = 'spotify:user:spotifycharts:playlist:3PGHzE2Tqab3V5xH6JyVcW'
results = sp.playlist_tracks(playlist_id, market=None)

fw = open("dump_tracks.json", "w")
fw.write(json.dumps(results, indent=4))

Expected behavior
I'd assume it prints the regular output except for the available_markets field.

Output

{
    "href": "https://api.spotify.com/v1/playlists/3PGHzE2Tqab3V5xH6JyVcW/tracks?offset=0&limit=100&additional_types=track",
    "items": [
        {
            "added_at": "2021-09-21T03:25:51Z",
            "added_by": {
                "external_urls": {
                    "spotify": "https://open.spotify.com/user/o99qu1ooqt549bm4nbw6bbrw5"
                },
                "href": "https://api.spotify.com/v1/users/o99qu1ooqt549bm4nbw6bbrw5",
                "id": "o99qu1ooqt549bm4nbw6bbrw5",
                "type": "user",
                "uri": "spotify:user:o99qu1ooqt549bm4nbw6bbrw5"
            },
            "is_local": false,
            "primary_color": null,
            "track": {
                "album": {
                    "album_type": "album",
                    "artists": [
                        {
                            "external_urls": {
                                "spotify": "https://open.spotify.com/artist/04gDigrS5kc9YWfZHwBETP"
                            },
                            "href": "https://api.spotify.com/v1/artists/04gDigrS5kc9YWfZHwBETP",
                            "id": "04gDigrS5kc9YWfZHwBETP",
                            "name": "Maroon 5",
                            "type": "artist",
                            "uri": "spotify:artist:04gDigrS5kc9YWfZHwBETP"
                        }
                    ],
                    "available_markets": [
                        "AE",
                        "AO",
                        "AU",
                        "BB",
                        "BF",
                        "BH",
                        "BY",
                        "CA",
                        "DZ",
                        "EG",
                        "GB",
                        "GH",
                        "IE",
                        "JO",
                        "JP",
                        "KG",
                        "KW",
                        "KZ",
                        "LB",
                        "MA",
                        "MX",
                        "NG",
                        "NP",
                        "OM",
                        "QA",
                        "RU",
                        "SA",
                        "TD",
                        "TN",
                        "TR",
                        "UA",
                        "US",
                        "UZ",
                        "ZA"
                    ],
                    "external_urls": {
                        "spotify": "https://open.spotify.com/album/0lHJwrDEFxrJhpB1gQoeMp"
                    },
# ... continued JSON string

Environment:

  • OS: Windows/Artix
  • Python version 3.9.7
  • spotipy version 2.19.0
  • your IDE VScode

Additional context
If I am just missing something stupid I'm sorry. But I'd like to get the results without it so I don't have to correct it in python.

Originally created by @Neopect on GitHub (Sep 24, 2021). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/731 **Describe the bug** When I use any of the playlist functions to fetch the contents of the playlist it returns the `available_markets` field regardless of setting `market=None`. **Your code** ``` from spotipy.oauth2 import SpotifyClientCredentials import spotipy import json sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials(client_id="clientID", client_secret="secret")) playlist_id = 'spotify:user:spotifycharts:playlist:3PGHzE2Tqab3V5xH6JyVcW' results = sp.playlist_tracks(playlist_id, market=None) fw = open("dump_tracks.json", "w") fw.write(json.dumps(results, indent=4)) ``` **Expected behavior** I'd assume it prints the regular output except for the `available_markets` field. **Output** ``` { "href": "https://api.spotify.com/v1/playlists/3PGHzE2Tqab3V5xH6JyVcW/tracks?offset=0&limit=100&additional_types=track", "items": [ { "added_at": "2021-09-21T03:25:51Z", "added_by": { "external_urls": { "spotify": "https://open.spotify.com/user/o99qu1ooqt549bm4nbw6bbrw5" }, "href": "https://api.spotify.com/v1/users/o99qu1ooqt549bm4nbw6bbrw5", "id": "o99qu1ooqt549bm4nbw6bbrw5", "type": "user", "uri": "spotify:user:o99qu1ooqt549bm4nbw6bbrw5" }, "is_local": false, "primary_color": null, "track": { "album": { "album_type": "album", "artists": [ { "external_urls": { "spotify": "https://open.spotify.com/artist/04gDigrS5kc9YWfZHwBETP" }, "href": "https://api.spotify.com/v1/artists/04gDigrS5kc9YWfZHwBETP", "id": "04gDigrS5kc9YWfZHwBETP", "name": "Maroon 5", "type": "artist", "uri": "spotify:artist:04gDigrS5kc9YWfZHwBETP" } ], "available_markets": [ "AE", "AO", "AU", "BB", "BF", "BH", "BY", "CA", "DZ", "EG", "GB", "GH", "IE", "JO", "JP", "KG", "KW", "KZ", "LB", "MA", "MX", "NG", "NP", "OM", "QA", "RU", "SA", "TD", "TN", "TR", "UA", "US", "UZ", "ZA" ], "external_urls": { "spotify": "https://open.spotify.com/album/0lHJwrDEFxrJhpB1gQoeMp" }, # ... continued JSON string ``` **Environment:** - OS: Windows/Artix - Python version 3.9.7 - spotipy version 2.19.0 - your IDE VScode **Additional context** If I am just missing something stupid I'm sorry. But I'd like to get the results without it so I don't have to correct it in python.
kerem 2026-02-27 23:22:38 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@Peter-Schorn commented on GitHub (Sep 24, 2021):

See the Track Relinking Guide.

<!-- gh-comment-id:926830728 --> @Peter-Schorn commented on GitHub (Sep 24, 2021): See the [Track Relinking Guide](https://developer.spotify.com/documentation/general/guides/track-relinking-guide/).
Author
Owner

@Neopect commented on GitHub (Sep 24, 2021):

Thank you for the URL, I found that I needed to specify the market value to remove the field, using something like market="US"

<!-- gh-comment-id:926861311 --> @Neopect commented on GitHub (Sep 24, 2021): Thank you for the URL, I found that I needed to specify the market value to remove the field, using something like `market="US"`
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#440
No description provided.