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

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

Merged

Conversation

jozefKruszynski
Copy link
Contributor

@jozefKruszynski jozefKruszynski commented Oct 22, 2023

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
Copy link
Collaborator

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

@jozefKruszynski
Copy link
Contributor Author

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.

@tehkillerbee tehkillerbee self-requested a review November 21, 2023 09:47
@jozefKruszynski jozefKruszynski marked this pull request as ready for review November 21, 2023 10:18
@jozefKruszynski
Copy link
Contributor Author

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

@tehkillerbee
Copy link
Collaborator

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

@jozefKruszynski
Copy link
Contributor Author

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

@jozefKruszynski
Copy link
Contributor Author

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

tidalapi/user.py Outdated Show resolved Hide resolved
Co-authored-by: Johannes L <[email protected]>
@tehkillerbee
Copy link
Collaborator

@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
Copy link
Collaborator

Works as expected and tests pass. Merged!

@tehkillerbee tehkillerbee merged commit fd81b6f into tamland:master Nov 29, 2023
5 checks passed
@jozefKruszynski
Copy link
Contributor Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants