Fix add-on paths playstate and Plex Companion for playlists
This commit is contained in:
parent
0a55e7fee8
commit
a36307e0aa
1 changed files with 24 additions and 10 deletions
|
@ -138,6 +138,18 @@ class SubscriptionMgr(object):
|
||||||
return server
|
return server
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_correct_position(info, playqueue):
|
||||||
|
"""
|
||||||
|
Kodi tells us the PLAYLIST position, not PLAYQUEUE position, if the
|
||||||
|
user initiated playback of a playlist
|
||||||
|
"""
|
||||||
|
if playqueue.kodi_playlist_playback:
|
||||||
|
position = 0
|
||||||
|
else:
|
||||||
|
position = info['position']
|
||||||
|
return position
|
||||||
|
|
||||||
@LOCKER.lockthis
|
@LOCKER.lockthis
|
||||||
def msg(self, players):
|
def msg(self, players):
|
||||||
"""
|
"""
|
||||||
|
@ -181,9 +193,9 @@ class SubscriptionMgr(object):
|
||||||
playerid = player['playerid']
|
playerid = player['playerid']
|
||||||
info = state.PLAYER_STATES[playerid]
|
info = state.PLAYER_STATES[playerid]
|
||||||
playqueue = PQ.PLAYQUEUES[playerid]
|
playqueue = PQ.PLAYQUEUES[playerid]
|
||||||
pos = info['position']
|
position = self._get_correct_position(info, playqueue)
|
||||||
try:
|
try:
|
||||||
item = playqueue.items[pos]
|
item = playqueue.items[position]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# E.g. for direct path playback for single item
|
# E.g. for direct path playback for single item
|
||||||
return {
|
return {
|
||||||
|
@ -236,7 +248,7 @@ class SubscriptionMgr(object):
|
||||||
answ['playQueueID'] = playqueue.id
|
answ['playQueueID'] = playqueue.id
|
||||||
answ['playQueueVersion'] = playqueue.version
|
answ['playQueueVersion'] = playqueue.version
|
||||||
answ['playQueueItemID'] = item.id
|
answ['playQueueItemID'] = item.id
|
||||||
if playqueue.items[pos].guid:
|
if playqueue.items[position].guid:
|
||||||
answ['guid'] = item.guid
|
answ['guid'] = item.guid
|
||||||
# Temp. token set?
|
# Temp. token set?
|
||||||
if state.PLEX_TRANSIENT_TOKEN:
|
if state.PLEX_TRANSIENT_TOKEN:
|
||||||
|
@ -286,7 +298,8 @@ class SubscriptionMgr(object):
|
||||||
"""
|
"""
|
||||||
playqueue = PQ.PLAYQUEUES[playerid]
|
playqueue = PQ.PLAYQUEUES[playerid]
|
||||||
info = state.PLAYER_STATES[playerid]
|
info = state.PLAYER_STATES[playerid]
|
||||||
return playqueue.items[info['position']].plex_stream_index(
|
position = self._get_correct_position(info, playqueue)
|
||||||
|
return playqueue.items[position].plex_stream_index(
|
||||||
info[STREAM_DETAILS[stream_type]]['index'], stream_type)
|
info[STREAM_DETAILS[stream_type]]['index'], stream_type)
|
||||||
|
|
||||||
@LOCKER.lockthis
|
@LOCKER.lockthis
|
||||||
|
@ -307,11 +320,9 @@ class SubscriptionMgr(object):
|
||||||
for player in players.values():
|
for player in players.values():
|
||||||
info = state.PLAYER_STATES[player['playerid']]
|
info = state.PLAYER_STATES[player['playerid']]
|
||||||
playqueue = PQ.PLAYQUEUES[player['playerid']]
|
playqueue = PQ.PLAYQUEUES[player['playerid']]
|
||||||
if playqueue.kodi_playlist_playback:
|
LOG.debug('playqueue is: %s', playqueue)
|
||||||
# Bug: Kodi will tell us the PLAYLIST instead of playqueue pos
|
LOG.debug('info is: %s', info)
|
||||||
position = 0
|
position = self._get_correct_position(info, playqueue)
|
||||||
else:
|
|
||||||
position = info['position']
|
|
||||||
try:
|
try:
|
||||||
item = playqueue.items[position]
|
item = playqueue.items[position]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
@ -349,6 +360,8 @@ class SubscriptionMgr(object):
|
||||||
|
|
||||||
def _notify_server(self, players):
|
def _notify_server(self, players):
|
||||||
for typus, player in players.iteritems():
|
for typus, player in players.iteritems():
|
||||||
|
LOG.debug('player is %s', player)
|
||||||
|
LOG.debug('typus is %s', typus)
|
||||||
self._send_pms_notification(
|
self._send_pms_notification(
|
||||||
player['playerid'], self._get_pms_params(player['playerid']))
|
player['playerid'], self._get_pms_params(player['playerid']))
|
||||||
try:
|
try:
|
||||||
|
@ -363,8 +376,9 @@ class SubscriptionMgr(object):
|
||||||
def _get_pms_params(self, playerid):
|
def _get_pms_params(self, playerid):
|
||||||
info = state.PLAYER_STATES[playerid]
|
info = state.PLAYER_STATES[playerid]
|
||||||
playqueue = PQ.PLAYQUEUES[playerid]
|
playqueue = PQ.PLAYQUEUES[playerid]
|
||||||
|
position = self._get_correct_position(info, playqueue)
|
||||||
try:
|
try:
|
||||||
item = playqueue.items[info['position']]
|
item = playqueue.items[position]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return self.last_params
|
return self.last_params
|
||||||
status = 'paused' if int(info['speed']) == 0 else 'playing'
|
status = 'paused' if int(info['speed']) == 0 else 'playing'
|
||||||
|
|
Loading…
Reference in a new issue