1
votes

The main python api "spotipy"(https://spotipy.readthedocs.io/en/latest/) only allows you to get playlists when provided the username and playlist id.

I want to extract tracklist with just the playlist ID or URI or URL. No username required.

I think it's possible looking at the Get A Playlist reference page but I can't decipher it - https://developer.spotify.com/documentation/web-api/reference/playlists/get-playlist/

Could you steer me in the right direction at least please?

1

1 Answers

0
votes

Im not 100% certain on the python syntax (sorry if it's not quite right) but could you add an additional method to your local spotipy/client.py file? It would be very similar to user_playlist/user_playlist_tracks but would bypass the need for a user id.

so, something like:

    def user_playlist_custom(self, playlist_id=None, fields=None):
        """ Gets playlist of a user
            Parameters:
                - playlist_id - the id of the playlist
                - fields - which fields to return
        """
        plid = self._get_id('playlist', playlist_id)
        return self._get("playlists/%s" % (plid), fields=fields)

or just the tracks:

    def user_playlist_tracks_custom(self, playlist_id=None, fields=None,
                             limit=100, offset=0, market=None):
        """ Get full details of the tracks of a playlist owned by a user.
            Parameters:
                - playlist_id - the id of the playlist
                - fields - which fields to return
                - limit - the maximum number of tracks to return
                - offset - the index of the first track to return
                - market - an ISO 3166-1 alpha-2 country code.
        """
        plid = self._get_id('playlist', playlist_id)
        return self._get("playlists/%s/tracks" % (plid),
                         limit=limit, offset=offset, fields=fields,
                         market=market)