Prefer local trailers; new setting to list extras instead of playing trailer

- Fixes #515
This commit is contained in:
croneter 2018-08-13 19:58:09 +02:00
parent abca9c32f9
commit ac2a57b28d
5 changed files with 28 additions and 11 deletions

View file

@ -464,6 +464,11 @@ msgctxt "#30513"
msgid "Limit artwork cache threads (recommended for rpi)"
msgstr ""
# PKC Settings - Sync Options
msgctxt "#30514"
msgid "Show all Plex extras instead of immediately playing trailers"
msgstr ""
# PKC Settings - Sync Options
msgctxt "#30515"
msgid "Maximum items to request from the server at once"

View file

@ -52,7 +52,8 @@ STATE_SETTINGS = {
'fetch_pms_item_number': 'FETCH_PMS_ITEM_NUMBER',
'imageSyncNotifications': 'IMAGE_SYNC_NOTIFICATIONS',
'syncSpecificPlexPlaylists': 'SYNC_SPECIFIC_PLEX_PLAYLISTS',
'syncSpecificKodiPlaylists': 'SYNC_SPECIFIC_KODI_PLAYLISTS'
'syncSpecificKodiPlaylists': 'SYNC_SPECIFIC_KODI_PLAYLISTS',
'showExtrasInsteadOfTrailer': 'SHOW_EXTRAS_INSTEAD_OF_PLAYING_TRAILER'
}
###############################################################################

View file

@ -743,26 +743,33 @@ class API(object):
def trailers(self):
"""
Returns the URL for a single trailer, an addon path for extras
(route_to_extras) if several trailers are present. Or None
Returns the URL for a single trailer (local trailer preferred; first
trailer found returned) or an add-on path to list all Plex extras
if the user setting showExtrasInsteadOfTrailer is set.
Returns None if nothing is found.
"""
url = None
number = 0
for extras in self.item.iterfind('Extras'):
# There will always be only 1 extras element
if (len(extras) > 0 and
state.SHOW_EXTRAS_INSTEAD_OF_PLAYING_TRAILER):
return ('plugin://%s?mode=route_to_extras&plex_id=%s'
% (v.ADDON_ID, self.plex_id()))
for extra in extras:
try:
typus = int(extra.attrib['extraType'])
except (KeyError, TypeError):
typus = None
if typus != 1:
# Skip non-trailers
continue
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:
if extra.get('guid', '').startswith('file:'):
url = extra.get('ratingKey')
# Always prefer local trailers (first one listed)
break
elif not url:
url = extra.get('ratingKey')
if url:
url = ('plugin://%s.movies/?plex_id=%s&plex_type=%s&mode=play'
% (v.ADDON_ID, url, v.PLEX_TYPE_CLIP))
return url

View file

@ -45,6 +45,9 @@ RESTRICTED_USER = False
DIRECT_PATHS = False
# Shall we replace custom user ratings with the number of versions available?
INDICATE_MEDIA_VERSIONS = False
# Will sync movie trailer differently: either play trailer directly or show
# all the Plex extras for the user to choose
SHOW_EXTRAS_INSTEAD_OF_PLAYING_TRAILER = False
# Do we need to run a special library scan?
RUN_LIB_SCAN = None
# Number of items to fetch and display in widgets

View file

@ -75,6 +75,7 @@
<setting id="backgroundsync_saftyMargin" type="slider" label="39051" default="5" option="int" range="5,1,300" visible="eq(-1,true)" subsetting="true" />
<setting type="sep" />
<setting type="lsep" label="30538" /><!-- Manual complete reset of Kodi database necessary, see "Advanced" -->
<setting id="showExtrasInsteadOfTrailer" type="bool" label="30514" default="false" /><!-- Show all Plex extras instead of immediately playing trailers -->
<setting id="indicate_media_versions" type="bool" label="39719" default="false" /><!-- Replace user ratings with number of versions -->
<setting id="enableMusic" type="bool" label="30509" default="true" />
<setting id="useDirectPaths" type="enum" label="30511" values="Addon(Default)|Native(Direct paths)" default="0" visible="true"/> <!-- Playback mode -->