Choose trailer if several are present (DB reset required)

- Fixes #515
This commit is contained in:
croneter 2018-08-04 15:11:21 +02:00
parent 8e5f6d5d6d
commit f5ea8cc3ec
3 changed files with 27 additions and 9 deletions

View file

@ -6,7 +6,7 @@ import logging
from sys import argv
from urlparse import parse_qsl
from xbmc import sleep, executebuiltin
from xbmcgui import ListItem
from xbmcgui import ListItem, getCurrentWindowId
from xbmcplugin import setResolvedUrl
from resources.lib import entrypoint, utils, pickler, pkc_listitem, \
@ -69,6 +69,16 @@ class Main():
elif mode == 'channels':
entrypoint.channels()
elif mode == 'route_to_extras':
# Hack so we can store this path in the Kodi DB
handle = ('plugin://%s?mode=extras&plex_id=%s'
% (v.ADDON_ID, params.get('plex_id')))
if getCurrentWindowId() == 10025:
# Video Window
executebuiltin('Container.Update(\"%s\")' % handle)
else:
executebuiltin('ActivateWindow(videos, \"%s\")' % handle)
elif mode == 'extras':
entrypoint.extras(plex_id=params.get('plex_id'))

View file

@ -207,11 +207,7 @@ class Movies(Items):
studio = studios[0]
except IndexError:
studio = None
trailer = api.trailer_id()
if trailer:
trailer = ('plugin://%s.movies/?plex_id=%s&plex_type=%s&mode=play'
% (v.ADDON_ID, trailer, v.PLEX_TYPE_CLIP))
trailer = api.trailers()
# GET THE FILE AND PATH #####
do_indirect = not state.DIRECT_PATHS

View file

@ -728,10 +728,13 @@ class API(object):
answ.append(extra)
return answ
def trailer_id(self):
def trailers(self):
"""
Returns the ratingKey (plex_id) of the trailer or None
Returns the URL for a single trailer, an addon path for extras
(route_to_extras) if several trailers are present. Or None
"""
url = None
number = 0
for extras in self.item.iterfind('Extras'):
for extra in extras:
try:
@ -740,7 +743,16 @@ class API(object):
typus = None
if typus != 1:
continue
return extra.get('ratingKey')
number += 1
url = extra.get('ratingKey')
if number > 1:
# Several trailers present. Hence let the user choose
url = ('plugin://%s?mode=route_to_extras&plex_id=%s'
% (v.ADDON_ID, self.plex_id()))
elif url:
url = ('plugin://%s.movies/?plex_id=%s&plex_type=%s&mode=play'
% (v.ADDON_ID, url, v.PLEX_TYPE_CLIP))
return url
def mediastreams(self):
"""