Skip to content

Commit

Permalink
Add experimental API mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
Erotemic committed Dec 11, 2023
1 parent 8eb392c commit 0cb18c1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions jellyfin_apiclient_python/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,34 @@ def new_sync_play_v2(self, group_name):
})


class ExperimentalAPIMixin:
"""
This is a location for testing proposed additions to the API Client.
"""
def get_now_playing(self, session_id):
"""
Simplified API to get now playing information for a session including the
play state.
References:
https://github.com/jellyfin/jellyfin/issues/9665
"""
resp = self.sessions(params={
'Id': session_id,
'fields': ['PlayState']
})
found = None
for item in resp:
if item['Id'] == session_id:
found = item
if not found:
raise KeyError(f'No session_id={session_id}')
play_state = found['PlayState']
now_playing = found['NowPlayingItem']
now_playing['PlayState'] = play_state
return now_playing


class API(InternalAPIMixin, BiggerAPIMixin, GranularAPIMixin,
SyncPlayAPIMixin):
"""
Expand Down

0 comments on commit 0cb18c1

Please sign in to comment.