From bdad905df3a0f7985b1e81c6f6add2c3f8daf200 Mon Sep 17 00:00:00 2001 From: croneter Date: Wed, 7 Feb 2018 13:32:10 +0100 Subject: [PATCH] Fix playback reporting not starting up correctly - Should fix #400 --- resources/lib/kodimonitor.py | 23 +++++++++++------------ resources/lib/playback.py | 3 --- resources/lib/playlist_func.py | 2 -- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index 6f05d127..232c1ab9 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -255,8 +255,8 @@ class KodiMonitor(Monitor): kodi_type = json_item.get('type') path = json_item.get('file') if not path and not kodi_id: - LOG.info('Aborting playback report - no Kodi id or file for %s', - json_item) + LOG.debug('Aborting playback report - no Kodi id or file for %s', + json_item) raise RuntimeError # Plex id will NOT be set with direct paths plex_id = state.PLEX_IDS.get(path) @@ -341,17 +341,7 @@ class KodiMonitor(Monitor): status = state.PLAYER_STATES[playerid] try: item = playqueue.items[pos] - # See if playback.py already initiated playback - init_done = item.init_done 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: kodi_id, kodi_type, plex_id, plex_type = self._get_ids(json_item) except RuntimeError: @@ -379,6 +369,15 @@ class KodiMonitor(Monitor): elif plex_id is not None: container_key = '/library/metadata/%s' % plex_id 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['container_key'] = container_key status['file'] = path diff --git a/resources/lib/playback.py b/resources/lib/playback.py index d20016bb..da9d8b9a 100644 --- a/resources/lib/playback.py +++ b/resources/lib/playback.py @@ -96,7 +96,6 @@ def play_resume(playqueue, xml, stack): item.playcount = stack_item['playcount'] item.offset = stack_item['offset'] item.part = stack_item['part'] - item.init_done = True api.CreateListItemFromPlexItem(listitem) playutils = PlayUtils(api, item) playurl = playutils.getPlayUrl() @@ -249,7 +248,6 @@ def _process_stack(playqueue, stack): playlist_item.part = item['part'] playlist_item.id = item['id'] playlist_item.force_transcode = state.FORCE_TRANSCODE - playlist_item.init_done = True pos += 1 @@ -339,7 +337,6 @@ def process_indirect(key, offset, resolve=True): item.offset = int(offset) item.plex_type = v.PLEX_TYPE_CLIP item.playmethod = 'DirectStream' - item.init_done = True # Need to get yet another xml to get the final playback url xml = DU().downloadUrl('http://node.plexapp.com:32400%s' % xml[0][0][0].attrib['key']) diff --git a/resources/lib/playlist_func.py b/resources/lib/playlist_func.py index 2571974b..99d39557 100644 --- a/resources/lib/playlist_func.py +++ b/resources/lib/playlist_func.py @@ -137,7 +137,6 @@ class Playlist_Item(object): 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 force_transcode [bool] defaults to False - init_done = False Set to True only if run through playback init """ def __init__(self): self.id = None @@ -156,7 +155,6 @@ class Playlist_Item(object): # If Plex video consists of several parts; part number self.part = 0 self.force_transcode = False - self.init_done = False def __repr__(self): """