Skip to content

Commit

Permalink
Return created and favorited playlists when getting favorited playlists
Browse files Browse the repository at this point in the history
Previously TIDAL returned both favorited and created playlists when
using the /users/USER_ID/favorites/playlists endpoint, this is not
the case anymore, and TIDAL instead has the new 50-limit endpoint
/users/USER_ID/playlistsAndFavoritePlaylists. This commit adds the
lists together using current functions for backwards compatibility
  • Loading branch information
morguldir committed Dec 4, 2020
1 parent 251ed48 commit c5a89b6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tidalapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,15 @@ def albums(self):
return self._session._map_request(self._base_url + '/albums', ret='albums')

def playlists(self):
return self._session._map_request(self._base_url + '/playlists', ret='playlists')
favorites = self._session._map_request(self._base_url + '/playlists', ret='playlists')
created_playlists = self._session.get_user_playlists(self._session.user.id)

# Don't append duplicates to the return value
for playlist in created_playlists:
if not any(playlist.id == favorite.id for favorite in favorites):
favorites.append(playlist)

return favorites

def tracks(self):
request = self._session.request('GET', self._base_url + '/tracks')
Expand Down

0 comments on commit c5a89b6

Please sign in to comment.