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.
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
(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)
# Have we already initiated playback?
try:
playqueue.items[pos]
item = playqueue.items[pos]
except IndexError:
# Release our default.py before starting our own Kodi player instance
if resolve is True:
@ -74,6 +77,18 @@ def playback_triage(plex_id=None, plex_type=None, path=None, resolve=True):
result.listitem = PKC_ListItem(path='PKC_Dummy_Path_Which_Fails')
pickle_me(result)
playback_init(plex_id, plex_type, playqueue)
else:
if item.playback_init is False:
# 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)

View file

@ -28,7 +28,7 @@ class Playback_Starter(Thread):
if mode == 'play':
playback.playback_triage(plex_id=params.get('plex_id'),
plex_type=params.get('plex_type'),
path=params.get('path'))
path=item)
elif mode == 'plex_node':
playback.process_indirect(params['key'], params['offset'])
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
part = 0 [int] part number if Plex video consists of mult. parts
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):
self.id = None
@ -156,6 +158,7 @@ class Playlist_Item(object):
# If Plex video consists of several parts; part number
self.part = 0
self.force_transcode = False
self.playback_init = False
def __repr__(self):
"""