tamland / python-tidal

Python API for TIDAL music streaming service
GNU Lesser General Public License v3.0
413 stars 110 forks source link

feat: Issue number 197 add v2 api favorite mixes #207

Closed jozefKruszynski closed 11 months ago

jozefKruszynski commented 1 year ago

I ended up having to create a MixV2 class as the structure is different enough to warrant it, however, this structure is only used for this one v2 api endpoint, and tidal themselves in their web app use the v1 api for every other call related to mixes.

It's a rather odd situation as you need to use the v2 endpoint to return a list of something that you then actually only ever need the name and ID of really.

I'll push a draft PR to make what I'm talking about a bit more tangible.

tehkillerbee commented 12 months ago

@jozefKruszynski Thanks for the PR. Can this be moved from draft or is more work needed on it?

jozefKruszynski commented 12 months ago

I left it as a draft, as I was hoping for some feedback on the code. I'll remove the draft as, I guess you'll be checking the code anyway.

jozefKruszynski commented 12 months ago

I'll fix the conflict later this evening, as I'm at work at the moment

tehkillerbee commented 11 months ago

@jozefKruszynski Looks like the typing additions I just merged resulted in new conflicts. Sorry!

jozefKruszynski commented 11 months ago

Having a hard time getting my changes to work as they did previously. I think I'm losing my mind

jozefKruszynski commented 11 months ago

Realised I had completely overcomplicated the whole thing. I have pushed a much simplified version

tehkillerbee commented 11 months ago

@jozefKruszynski

A sidenote, after looking more into the tidal2 plugin for KODI, I noticed that there are a few endpoints that use the V2 API

    def get_followers(self, user_id, offset=0, limit=500):
        return self._map_request_v2('profiles/%s/followers' % user_id, params={'deviceType': 'BROWSER'}, ret='userprofiles')

    def get_following_users(self, user_id, offset=0, limit=500):
        return self._map_request_v2('profiles/%s/following' % user_id, params={'includeOnly': 'USER', 'deviceType': 'BROWSER'}, ret='userprofiles')

    def get_following_artists(self, user_id, offset=0, limit=500):
        return self._map_request_v2('profiles/%s/following' % user_id, params={'includeOnly': 'ARTIST', 'deviceType': 'BROWSER'}, ret='artists')

    def get_public_playlists(self, user_id, offset=0, limit=50):
        return self._map_request_v2('user-playlists/%s/public' % user_id, params={'offset': offset, 'limit': limit}, ret='playlists')
tehkillerbee commented 11 months ago

Works as expected and tests pass. Merged!

jozefKruszynski commented 11 months ago

@jozefKruszynski

A sidenote, after looking more into the tidal2 plugin for KODI, I noticed that there are a few endpoints that use the V2 API


    def get_followers(self, user_id, offset=0, limit=500):

        return self._map_request_v2('profiles/%s/followers' % user_id, params={'deviceType': 'BROWSER'}, ret='userprofiles')

    def get_following_users(self, user_id, offset=0, limit=500):

        return self._map_request_v2('profiles/%s/following' % user_id, params={'includeOnly': 'USER', 'deviceType': 'BROWSER'}, ret='userprofiles')

    def get_following_artists(self, user_id, offset=0, limit=500):

        return self._map_request_v2('profiles/%s/following' % user_id, params={'includeOnly': 'ARTIST', 'deviceType': 'BROWSER'}, ret='artists')

    def get_public_playlists(self, user_id, offset=0, limit=50):

        return self._map_request_v2('user-playlists/%s/public' % user_id, params={'offset': offset, 'limit': limit}, ret='playlists')

I guess a robust V2 solution is not what I have produced at all. We can look into a proper implementation in the near future I hope. Work is a bitch at the moment