Attempt to fix Kodi overwriting paths in Kodi DB

This commit is contained in:
croneter 2018-02-17 13:42:08 +01:00
parent ab1f28bb88
commit 8cd9deef40
3 changed files with 22 additions and 4 deletions

View file

@ -36,6 +36,9 @@ def playback_triage(plex_id=None, plex_type=None, path=None, resolve=True):
Hit this function for addon path playback, Plex trailers, etc. Hit this function for addon path playback, Plex trailers, etc.
Will setup playback first, then on second call complete playback. Will setup playback first, then on second call complete playback.
path: either the complete plugin://plugin.video.plexkodiconnect path
OR just the query '?plex_id=458160&mode=play&plex_type=movie'
Will set Playback_Successful() with potentially a PKC_ListItem() attached Will set Playback_Successful() with potentially a PKC_ListItem() attached
(to be consumed by setResolvedURL in default.py) (to be consumed by setResolvedURL in default.py)
@ -65,7 +68,7 @@ def playback_triage(plex_id=None, plex_type=None, path=None, resolve=True):
LOG.debug('playQueue position: %s for %s', pos, playqueue) LOG.debug('playQueue position: %s for %s', pos, playqueue)
# Have we already initiated playback? # Have we already initiated playback?
try: try:
playqueue.items[pos] item = playqueue.items[pos]
except IndexError: except IndexError:
# Release our default.py before starting our own Kodi player instance # Release our default.py before starting our own Kodi player instance
if resolve is True: if resolve is True:
@ -75,8 +78,20 @@ def playback_triage(plex_id=None, plex_type=None, path=None, resolve=True):
pickle_me(result) pickle_me(result)
playback_init(plex_id, plex_type, playqueue) playback_init(plex_id, plex_type, playqueue)
else: else:
# kick off playback on second pass if item.playback_init is False:
conclude_playback(playqueue, pos) # Hack: we need to use setResolvedUrl twice. Otherwise, Kodi
# overwrites the path in the Kodi database (addon-path) with the
# result of the first setResolvedUrl
item.playback_init = True
if not path.startswith('plugin://'):
path = 'plugin://%s%s' % (v.ADDON_ID, path)
LOG.debug('Initializing playback for one item using path %s', path)
result = Playback_Successful()
result.listitem = PKC_ListItem(path=path)
pickle_me(result)
else:
# kick off playback on second pass
conclude_playback(playqueue, pos)
def playback_init(plex_id, plex_type, playqueue): def playback_init(plex_id, plex_type, playqueue):

View file

@ -28,7 +28,7 @@ class Playback_Starter(Thread):
if mode == 'play': if mode == 'play':
playback.playback_triage(plex_id=params.get('plex_id'), playback.playback_triage(plex_id=params.get('plex_id'),
plex_type=params.get('plex_type'), plex_type=params.get('plex_type'),
path=params.get('path')) path=item)
elif mode == 'plex_node': elif mode == 'plex_node':
playback.process_indirect(params['key'], params['offset']) playback.process_indirect(params['key'], params['offset'])
elif mode == 'context_menu': elif mode == 'context_menu':

View file

@ -138,6 +138,8 @@ 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
playback_init [bool] Hack to use setResolvedUrl twice (and thus only
"correctly") if playback_init is set to True
""" """
def __init__(self): def __init__(self):
self.id = None self.id = None
@ -156,6 +158,7 @@ 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.playback_init = False
def __repr__(self): def __repr__(self):
""" """