Fix playback reporting not starting up correctly

- Should fix #400
This commit is contained in:
croneter 2018-02-07 13:32:10 +01:00
parent 447d233df1
commit bdad905df3
3 changed files with 11 additions and 17 deletions

View file

@ -255,7 +255,7 @@ class KodiMonitor(Monitor):
kodi_type = json_item.get('type') kodi_type = json_item.get('type')
path = json_item.get('file') path = json_item.get('file')
if not path and not kodi_id: if not path and not kodi_id:
LOG.info('Aborting playback report - no Kodi id or file for %s', LOG.debug('Aborting playback report - no Kodi id or file for %s',
json_item) json_item)
raise RuntimeError raise RuntimeError
# Plex id will NOT be set with direct paths # Plex id will NOT be set with direct paths
@ -341,17 +341,7 @@ class KodiMonitor(Monitor):
status = state.PLAYER_STATES[playerid] status = state.PLAYER_STATES[playerid]
try: try:
item = playqueue.items[pos] item = playqueue.items[pos]
# See if playback.py already initiated playback
init_done = item.init_done
except IndexError: except IndexError:
init_done = False
if init_done is True:
kodi_id = item.kodi_id
kodi_type = item.kodi_type
plex_id = item.plex_id
plex_type = item.plex_type
container_key = '/playQueues/%s' % playqueue.id
else:
try: try:
kodi_id, kodi_type, plex_id, plex_type = self._get_ids(json_item) kodi_id, kodi_type, plex_id, plex_type = self._get_ids(json_item)
except RuntimeError: except RuntimeError:
@ -379,6 +369,15 @@ class KodiMonitor(Monitor):
elif plex_id is not None: elif plex_id is not None:
container_key = '/library/metadata/%s' % plex_id container_key = '/library/metadata/%s' % plex_id
LOG.debug('Set the Plex container_key to: %s', container_key) LOG.debug('Set the Plex container_key to: %s', container_key)
else:
kodi_id = item.kodi_id
kodi_type = item.kodi_type
plex_id = item.plex_id
plex_type = item.plex_type
if playqueue.id:
container_key = '/playQueues/%s' % playqueue.id
else:
container_key = '/library/metadata/%s' % plex_id
status.update(info) status.update(info)
status['container_key'] = container_key status['container_key'] = container_key
status['file'] = path status['file'] = path

View file

@ -96,7 +96,6 @@ def play_resume(playqueue, xml, stack):
item.playcount = stack_item['playcount'] item.playcount = stack_item['playcount']
item.offset = stack_item['offset'] item.offset = stack_item['offset']
item.part = stack_item['part'] item.part = stack_item['part']
item.init_done = True
api.CreateListItemFromPlexItem(listitem) api.CreateListItemFromPlexItem(listitem)
playutils = PlayUtils(api, item) playutils = PlayUtils(api, item)
playurl = playutils.getPlayUrl() playurl = playutils.getPlayUrl()
@ -249,7 +248,6 @@ def _process_stack(playqueue, stack):
playlist_item.part = item['part'] playlist_item.part = item['part']
playlist_item.id = item['id'] playlist_item.id = item['id']
playlist_item.force_transcode = state.FORCE_TRANSCODE playlist_item.force_transcode = state.FORCE_TRANSCODE
playlist_item.init_done = True
pos += 1 pos += 1
@ -339,7 +337,6 @@ def process_indirect(key, offset, resolve=True):
item.offset = int(offset) item.offset = int(offset)
item.plex_type = v.PLEX_TYPE_CLIP item.plex_type = v.PLEX_TYPE_CLIP
item.playmethod = 'DirectStream' item.playmethod = 'DirectStream'
item.init_done = True
# Need to get yet another xml to get the final playback url # Need to get yet another xml to get the final playback url
xml = DU().downloadUrl('http://node.plexapp.com:32400%s' xml = DU().downloadUrl('http://node.plexapp.com:32400%s'
% xml[0][0][0].attrib['key']) % xml[0][0][0].attrib['key'])

View file

@ -137,7 +137,6 @@ class Playlist_Item(object):
offset = None [int] the item's view offset UPON START in Plex time offset = None [int] the item's view offset UPON START in Plex time
part = 0 [int] part number if Plex video consists of mult. parts part = 0 [int] part number if Plex video consists of mult. parts
force_transcode [bool] defaults to False force_transcode [bool] defaults to False
init_done = False Set to True only if run through playback init
""" """
def __init__(self): def __init__(self):
self.id = None self.id = None
@ -156,7 +155,6 @@ class Playlist_Item(object):
# If Plex video consists of several parts; part number # If Plex video consists of several parts; part number
self.part = 0 self.part = 0
self.force_transcode = False self.force_transcode = False
self.init_done = False
def __repr__(self): def __repr__(self):
""" """