Skip to content

Commit

Permalink
Merge pull request #136 from mcarlton00/playlist-objects
Browse files Browse the repository at this point in the history
Search for playlist objects instead of a playlists library
  • Loading branch information
mcarlton00 committed Dec 22, 2022
2 parents 23d8b1f + ec32c85 commit 11befca
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions mopidy_jellyfin/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,20 @@ def get_library_roots(self):
]

def get_playlists(self):
url = self.api_url(
'/Users/{}/Views'.format(self.user_id)
)

data = self.http.get(url)

library_id = [
library.get('Id') for library in data.get('Items')
if library.get('Name') == 'Playlists'
]

if library_id:
library_id = library_id[0]
else:
return []
'''
Queries the server for any playlist objects
'''
url_params = {
'UserId': self.user_id,
'IncludeItemTypes': 'Playlist',
'Recursive': 'true',
'fields': 'MediaSources'
}

raw_playlists = self.get_directory(library_id)
url = self.api_url('/Users/{}/Items'.format(self.user_id), url_params)
playlists = self.http.get(url)

return raw_playlists.get('Items')
return playlists.get('Items', [])

def get_playlist_contents(self, playlist_id):
url_params = {
Expand Down

0 comments on commit 11befca

Please sign in to comment.