Fix resume for On Deck widget for direct paths
This commit is contained in:
parent
cfecee44bf
commit
2f90a29acf
2 changed files with 29 additions and 17 deletions
|
@ -99,15 +99,20 @@ class API(object):
|
||||||
"""
|
"""
|
||||||
return self.item.get('ratingKey')
|
return self.item.get('ratingKey')
|
||||||
|
|
||||||
def path(self, force_first_media=True, force_addon=False):
|
def path(self, force_first_media=True, force_addon=False,
|
||||||
|
direct_paths=None):
|
||||||
"""
|
"""
|
||||||
Returns a "fully qualified path": add-on paths or direct paths
|
Returns a "fully qualified path": add-on paths or direct paths
|
||||||
depending on the current settings. Will NOT valide the playurl
|
depending on the current settings. Will NOT valide the playurl
|
||||||
Returns unicode or None if something went wrong.
|
Returns unicode or None if something went wrong.
|
||||||
|
|
||||||
|
Pass direct_path=True if you're calling from another Plex python
|
||||||
|
instance - because otherwise direct paths will evaluate to False!
|
||||||
"""
|
"""
|
||||||
|
direct_paths = direct_paths or state.DIRECT_PATHS
|
||||||
filename = self.file_path(force_first_media=force_first_media)
|
filename = self.file_path(force_first_media=force_first_media)
|
||||||
if (not state.DIRECT_PATHS or force_addon
|
if (not direct_paths or force_addon or
|
||||||
or self.plex_type() == v.PLEX_TYPE_CLIP):
|
self.plex_type() == v.PLEX_TYPE_CLIP):
|
||||||
if filename and '/' in filename:
|
if filename and '/' in filename:
|
||||||
filename = filename.rsplit('/', 1)
|
filename = filename.rsplit('/', 1)
|
||||||
elif filename:
|
elif filename:
|
||||||
|
|
|
@ -529,40 +529,45 @@ def getOnDeck(viewid, mediatype, tagname, limit):
|
||||||
xbmcplugin.setContent(HANDLE, 'episodes')
|
xbmcplugin.setContent(HANDLE, 'episodes')
|
||||||
append_show_title = settings('OnDeckTvAppendShow') == 'true'
|
append_show_title = settings('OnDeckTvAppendShow') == 'true'
|
||||||
append_sxxexx = settings('OnDeckTvAppendSeason') == 'true'
|
append_sxxexx = settings('OnDeckTvAppendSeason') == 'true'
|
||||||
directpaths = settings('useDirectPaths') == 'true'
|
|
||||||
if settings('OnDeckTVextended') == 'false':
|
if settings('OnDeckTVextended') == 'false':
|
||||||
# Chances are that this view is used on Kodi startup
|
# Chances are that this view is used on Kodi startup
|
||||||
# Wait till we've connected to a PMS. At most 30s
|
# Wait till we've connected to a PMS. At most 30s
|
||||||
counter = 0
|
counter = 0
|
||||||
while window('plex_authenticated') != 'true':
|
while window('plex_authenticated') != 'true':
|
||||||
counter += 1
|
counter += 1
|
||||||
if counter >= 300:
|
if counter == 300:
|
||||||
log.error('Aborting On Deck view, we were not authenticated '
|
log.error('Aborting On Deck view, we were not authenticated '
|
||||||
'for the PMS')
|
'for the PMS')
|
||||||
return xbmcplugin.endOfDirectory(HANDLE, False)
|
xbmcplugin.endOfDirectory(HANDLE, False)
|
||||||
|
return
|
||||||
sleep(100)
|
sleep(100)
|
||||||
xml = downloadutils.DownloadUtils().downloadUrl(
|
xml = downloadutils.DownloadUtils().downloadUrl(
|
||||||
'{server}/library/sections/%s/onDeck' % viewid)
|
'{server}/library/sections/%s/onDeck' % viewid)
|
||||||
if xml in (None, 401):
|
if xml in (None, 401):
|
||||||
log.error('Could not download PMS xml for view %s' % viewid)
|
log.error('Could not download PMS xml for view %s' % viewid)
|
||||||
return xbmcplugin.endOfDirectory(HANDLE)
|
xbmcplugin.endOfDirectory(HANDLE, False)
|
||||||
limitcounter = 0
|
return
|
||||||
|
direct_paths = settings('useDirectPaths') == '1'
|
||||||
|
counter = 0
|
||||||
for item in xml:
|
for item in xml:
|
||||||
api = API(item)
|
api = API(item)
|
||||||
listitem = api.create_listitem(
|
listitem = api.create_listitem(
|
||||||
append_show_title=append_show_title,
|
append_show_title=append_show_title,
|
||||||
append_sxxexx=append_sxxexx)
|
append_sxxexx=append_sxxexx)
|
||||||
url = api.path()
|
if api.resume_point():
|
||||||
|
listitem.setProperty('resumetime', str(api.resume_point()))
|
||||||
|
path = api.path(force_first_media=False, direct_paths=direct_paths)
|
||||||
xbmcplugin.addDirectoryItem(
|
xbmcplugin.addDirectoryItem(
|
||||||
handle=HANDLE,
|
handle=HANDLE,
|
||||||
url=url,
|
url=path,
|
||||||
listitem=listitem)
|
listitem=listitem)
|
||||||
limitcounter += 1
|
counter += 1
|
||||||
if limitcounter == limit:
|
if counter == limit:
|
||||||
break
|
break
|
||||||
return xbmcplugin.endOfDirectory(
|
xbmcplugin.endOfDirectory(
|
||||||
handle=HANDLE,
|
handle=HANDLE,
|
||||||
cacheToDisc=settings('enableTextureCache') == 'true')
|
cacheToDisc=settings('enableTextureCache') == 'true')
|
||||||
|
return
|
||||||
|
|
||||||
# if the addon is called with nextup parameter,
|
# if the addon is called with nextup parameter,
|
||||||
# we return the nextepisodes list of the given tagname
|
# we return the nextepisodes list of the given tagname
|
||||||
|
@ -661,8 +666,9 @@ def watchlater():
|
||||||
|
|
||||||
log.info('Displaying watch later plex.tv items')
|
log.info('Displaying watch later plex.tv items')
|
||||||
xbmcplugin.setContent(HANDLE, 'movies')
|
xbmcplugin.setContent(HANDLE, 'movies')
|
||||||
|
direct_paths = settings('useDirectPaths') == '1'
|
||||||
for item in xml:
|
for item in xml:
|
||||||
__build_item(item)
|
__build_item(item, direct_paths)
|
||||||
|
|
||||||
xbmcplugin.endOfDirectory(
|
xbmcplugin.endOfDirectory(
|
||||||
handle=HANDLE,
|
handle=HANDLE,
|
||||||
|
@ -715,12 +721,13 @@ def browse_plex(key=None, plex_section_id=None):
|
||||||
artists = False
|
artists = False
|
||||||
albums = False
|
albums = False
|
||||||
musicvideos = False
|
musicvideos = False
|
||||||
|
direct_paths = settings('useDirectPaths') == '1'
|
||||||
for item in xml:
|
for item in xml:
|
||||||
if item.tag == 'Directory':
|
if item.tag == 'Directory':
|
||||||
__build_folder(item, plex_section_id=plex_section_id)
|
__build_folder(item, plex_section_id=plex_section_id)
|
||||||
else:
|
else:
|
||||||
typus = item.attrib.get('type')
|
typus = item.attrib.get('type')
|
||||||
__build_item(item)
|
__build_item(item, direct_paths)
|
||||||
if typus == v.PLEX_TYPE_PHOTO:
|
if typus == v.PLEX_TYPE_PHOTO:
|
||||||
photos = True
|
photos = True
|
||||||
elif typus == v.PLEX_TYPE_MOVIE:
|
elif typus == v.PLEX_TYPE_MOVIE:
|
||||||
|
@ -803,7 +810,7 @@ def __build_folder(xml_element, plex_section_id=None):
|
||||||
listitem=listitem)
|
listitem=listitem)
|
||||||
|
|
||||||
|
|
||||||
def __build_item(xml_element):
|
def __build_item(xml_element, direct_paths):
|
||||||
api = API(xml_element)
|
api = API(xml_element)
|
||||||
listitem = api.create_listitem()
|
listitem = api.create_listitem()
|
||||||
resume = api.resume_point()
|
resume = api.resume_point()
|
||||||
|
@ -820,7 +827,7 @@ def __build_item(xml_element):
|
||||||
elif api.plex_type() == v.PLEX_TYPE_PHOTO:
|
elif api.plex_type() == v.PLEX_TYPE_PHOTO:
|
||||||
url = api.get_picture_path()
|
url = api.get_picture_path()
|
||||||
else:
|
else:
|
||||||
url = api.path()
|
url = api.path(direct_paths=direct_paths)
|
||||||
if api.resume_point():
|
if api.resume_point():
|
||||||
listitem.setProperty('resumetime', str(api.resume_point()))
|
listitem.setProperty('resumetime', str(api.resume_point()))
|
||||||
xbmcplugin.addDirectoryItem(handle=HANDLE,
|
xbmcplugin.addDirectoryItem(handle=HANDLE,
|
||||||
|
|
Loading…
Add table
Reference in a new issue