New setting to use Plex default subtitles

This commit is contained in:
tomkat83 2016-09-08 14:50:49 +02:00
parent 143fd2212d
commit f2f68f4532
4 changed files with 25 additions and 19 deletions

View file

@ -422,6 +422,7 @@
<string id="39072">Is your Kodi installed on a low-powered device like a Raspberry Pi? If yes, then we will reduce the strain on Kodi to prevent it from crashing.</string> <string id="39072">Is your Kodi installed on a low-powered device like a Raspberry Pi? If yes, then we will reduce the strain on Kodi to prevent it from crashing.</string>
<string id="39073">Appearance Tweaks</string> <string id="39073">Appearance Tweaks</string>
<string id="39074">TV Shows</string> <string id="39074">TV Shows</string>
<string id="39075">Always use default Plex subtitle if possible</string>
<!-- Plex Entrypoint.py --> <!-- Plex Entrypoint.py -->
<string id="39200">Log-out Plex Home User </string> <string id="39200">Log-out Plex Home User </string>

View file

@ -360,6 +360,7 @@
<string id="39072">Läuft Kodi auf einem Raspberry Pi oder ähnlichem Gerät mit äusserst wenig Rechenleistung? Falls ja, wird die Rechenlast reduziert, damit Kodi nicht abstürzt.</string> <string id="39072">Läuft Kodi auf einem Raspberry Pi oder ähnlichem Gerät mit äusserst wenig Rechenleistung? Falls ja, wird die Rechenlast reduziert, damit Kodi nicht abstürzt.</string>
<string id="39073">Tweaks Aussehen</string> <string id="39073">Tweaks Aussehen</string>
<string id="39074">TV Serien</string> <string id="39074">TV Serien</string>
<string id="39075">Falls möglich, Plex Standard-Untertitel anzeigen</string>
<!-- Plex Entrypoint.py --> <!-- Plex Entrypoint.py -->
<string id="39200">Plex Home Benutzer abmelden: </string> <string id="39200">Plex Home Benutzer abmelden: </string>

View file

@ -295,6 +295,7 @@ class PlayUtils():
audioNum = 0 audioNum = 0
# Remember 'no subtitles' # Remember 'no subtitles'
subNum = 1 subNum = 1
defaultSub = None
for stream in mediastreams: for stream in mediastreams:
# Since Plex returns all possible tracks together, have to sort # Since Plex returns all possible tracks together, have to sort
# them. # them.
@ -316,8 +317,6 @@ class PlayUtils():
# Subtitles # Subtitles
elif type == "3": elif type == "3":
'''if stream['IsExternal']:
continue'''
try: try:
track = "%s %s" % (subNum+1, stream.attrib['language']) track = "%s %s" % (subNum+1, stream.attrib['language'])
except: except:
@ -333,6 +332,10 @@ class PlayUtils():
track = "%s - Forced" % track track = "%s - Forced" % track
if downloadable: if downloadable:
downloadableStreams.append(index) downloadableStreams.append(index)
if stream.attrib.get('selected') == '1' and downloadable:
# Only show subs without asking user if they can be
# turned off
defaultSub = index
else: else:
track = "%s (burn-in)" % track track = "%s (burn-in)" % track
@ -353,35 +356,35 @@ class PlayUtils():
# Add audio boost # Add audio boost
playurlprefs['audioBoost'] = settings('audioBoost') playurlprefs['audioBoost'] = settings('audioBoost')
selectSubsIndex = None
if subNum > 1: if subNum > 1:
resp = dialog.select(lang(33014), subtitleStreams) if (settings('pickPlexSubtitles') == 'true' and
if resp == 0: defaultSub is not None):
# User selected no subtitles log.info('Using default Plex subtitle: %s' % defaultSub)
playurlprefs["skipSubtitles"] = 1 selectSubsIndex = defaultSub
elif resp > -1: else:
# User selected subtitles resp = dialog.select(lang(33014), subtitleStreams)
selectSubsIndex = subtitleStreamsList[resp-1] if resp > 0:
selectSubsIndex = subtitleStreamsList[resp-1]
else:
# User selected no subtitles or backed out of dialog
playurlprefs["skipSubtitles"] = 1
if selectSubsIndex is not None:
# Load subtitles in the listitem if downloadable # Load subtitles in the listitem if downloadable
if selectSubsIndex in downloadableStreams: if selectSubsIndex in downloadableStreams:
sub_url = self.API.addPlexHeadersToUrl( sub_url = self.API.addPlexHeadersToUrl(
"%s/library/streams/%s" "%s/library/streams/%s"
% (self.server, selectSubsIndex)) % (self.server, selectSubsIndex))
log.info("Downloadable sub: %s: %s" log.info("Downloadable sub: %s: %s"
% (selectSubsIndex, sub_url)) % (selectSubsIndex, sub_url))
listitem.setSubtitles([tryEncode(sub_url)]) listitem.setSubtitles([tryEncode(sub_url)])
# Don't additionally burn in subtitles
playurlprefs["skipSubtitles"] = 1
else: else:
log.info('Need to burn in subtitle %s' % selectSubsIndex) log.info('Need to burn in subtitle %s' % selectSubsIndex)
playurlprefs["subtitleStreamID"] = selectSubsIndex playurlprefs["subtitleStreamID"] = selectSubsIndex
playurlprefs["subtitleSize"] = settings('subtitleSize') playurlprefs["subtitleSize"] = settings('subtitleSize')
else: # User backed out of selection
pass
# Tell the PMS what we want with a PUT request
# url = self.server + '/library/parts/' + self.item[0][part].attrib['id']
# PlexFunctions.SelectStreams(url, playurlprefs)
url += '&' + urlencode(playurlprefs) url += '&' + urlencode(playurlprefs)
# Get number of channels for selected audio track # Get number of channels for selected audio track

View file

@ -81,11 +81,10 @@
<category label="30516"><!-- Playback --> <category label="30516"><!-- Playback -->
<setting type="sep" /> <setting type="sep" />
<setting id="bestQuality" type="bool" label="30541" default="false" />
<setting id="bestTrailer" type="bool" label="30542" default="true" />
<setting id="enableCinema" type="bool" label="30518" default="true" /> <setting id="enableCinema" type="bool" label="30518" default="true" />
<setting id="askCinema" type="bool" label="30519" default="false" visible="eq(-1,true)" subsetting="true" /> <setting id="askCinema" type="bool" label="30519" default="false" visible="eq(-1,true)" subsetting="true" />
<setting id="trailerNumber" type="slider" label="39000" default="3" visible="eq(-2,true)" range="1,1,15" option="int" /> <setting id="trailerNumber" type="slider" label="39000" default="3" visible="eq(-2,true)" range="1,1,15" option="int" />
<setting id="pickPlexSubtitles" type="bool" label="39075" default="true" />
<setting id="ignoreSpecialsNextEpisodes" type="bool" label="30527" default="false" /> <setting id="ignoreSpecialsNextEpisodes" type="bool" label="30527" default="false" />
<setting id="offerDelete" type="bool" label="30114" default="false" visible="false"/> <setting id="offerDelete" type="bool" label="30114" default="false" visible="false"/>
<setting id="deleteTV" type="bool" label="30115" visible="eq(-1,true)" default="false" subsetting="true" /> <setting id="deleteTV" type="bool" label="30115" visible="eq(-1,true)" default="false" subsetting="true" />
@ -101,6 +100,8 @@
<setting id="subtitleSize" label="39002" type="slider" option="int" range="0,30,300" default="100" /> <setting id="subtitleSize" label="39002" type="slider" option="int" range="0,30,300" default="100" />
<setting id="failedCount" type="number" visible="false" default="0" /> <setting id="failedCount" type="number" visible="false" default="0" />
<setting id="networkCreds" type="text" visible="false" default="" /> <setting id="networkCreds" type="text" visible="false" default="" />
<setting id="bestQuality" type="bool" label="30541" default="false" />
<setting id="bestTrailer" type="bool" label="30542" default="true" />
</category> </category>
<!-- <!--