When transcoding, only let user choose to burn-in subtitles that can't be displayed otherwise by Kodi

This commit is contained in:
croneter 2020-02-23 15:31:37 +01:00
parent 310ae54e7b
commit 1021c47b04
3 changed files with 38 additions and 53 deletions

View file

@ -1060,11 +1060,6 @@ msgctxt "#39074"
msgid "TV Shows" msgid "TV Shows"
msgstr "" msgstr ""
# PKC Settings - Playback
msgctxt "#39075"
msgid "Always use default Plex subtitle if possible"
msgstr ""
# Pop-up during initial sync # Pop-up during initial sync
msgctxt "#39076" msgctxt "#39076"
msgid "If you use several Plex libraries of one kind, e.g. \"Kids Movies\" and \"Parents Movies\", be sure to check the Wiki: https://goo.gl/JFtQV9" msgid "If you use several Plex libraries of one kind, e.g. \"Kids Movies\" and \"Parents Movies\", be sure to check the Wiki: https://goo.gl/JFtQV9"
@ -1369,9 +1364,9 @@ msgid "Use at your own risk"
msgstr "" msgstr ""
# If user gets prompted to choose between several subtitles. Leave the number one at the beginning of the string! # If user gets prompted to choose between several subtitles to burn in
msgctxt "#39706" msgctxt "#39706"
msgid "1 No subtitles" msgid "Don't burn-in any subtitle"
msgstr "" msgstr ""
# If user gets prompted to choose between several audio/subtitle tracks and language is unknown # If user gets prompted to choose between several audio/subtitle tracks and language is unknown

View file

@ -337,8 +337,8 @@ def audio_subtitle_prefs(api, listitem):
audio_streams_list = [] audio_streams_list = []
audio_streams = [] audio_streams = []
subtitle_streams_list = [] subtitle_streams_list = []
# No subtitles as an option # "Don't burn-in any subtitle"
subtitle_streams = [utils.lang(39706)] subtitle_streams = ['1 %s' % utils.lang(39706)]
downloadable_streams = [] downloadable_streams = []
download_subs = [] download_subs = []
# selectAudioIndex = "" # selectAudioIndex = ""
@ -346,7 +346,6 @@ def audio_subtitle_prefs(api, listitem):
audio_numb = 0 audio_numb = 0
# Remember 'no subtitles' # Remember 'no subtitles'
sub_num = 1 sub_num = 1
default_sub = 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
@ -373,21 +372,11 @@ def audio_subtitle_prefs(api, listitem):
# Subtitles # Subtitles
elif typus == "3": elif typus == "3":
try:
track = '{} {}'.format(sub_num, stream.attrib['displayTitle'])
except KeyError:
track = '{} {} ({})'.format(sub_num + 1,
utils.lang(39707), # unknown
stream.get('codec'))
default = stream.get('default')
forced = stream.get('forced')
downloadable = stream.get('key') downloadable = stream.get('key')
if default:
track = "%s - %s" % (track, utils.lang(39708)) # Default
if forced:
track = "%s - %s" % (track, utils.lang(39709)) # Forced
if downloadable: if downloadable:
# Download the subtitle to Kodi - the user will need to
# manually select the subtitle on the Kodi side
# Hence do NOT show dialog for this sub
path = api.download_external_subtitles( path = api.download_external_subtitles(
'{{server}}{}'.format(stream.get('key')), '{{server}}{}'.format(stream.get('key')),
stream.get('displayTitle'), stream.get('displayTitle'),
@ -396,15 +385,24 @@ def audio_subtitle_prefs(api, listitem):
downloadable_streams.append(index) downloadable_streams.append(index)
download_subs.append(path.encode('utf-8')) download_subs.append(path.encode('utf-8'))
else: else:
# Burn in the subtitle, if user chooses to do so
default = stream.get('default')
forced = stream.get('forced')
try:
track = '{} {}'.format(sub_num + 1,
stream.attrib['displayTitle'])
except KeyError:
track = '{} {} ({})'.format(sub_num + 1,
utils.lang(39707), # unknown
stream.get('codec'))
if default:
track = "%s - %s" % (track, utils.lang(39708)) # Default
if forced:
track = "%s - %s" % (track, utils.lang(39709)) # Forced
track = "%s (%s)" % (track, utils.lang(39710)) # burn-in track = "%s (%s)" % (track, utils.lang(39710)) # burn-in
if stream.get('selected') == '1' and downloadable: subtitle_streams_list.append(index)
# Only show subs without asking user if they can be subtitle_streams.append(track.encode('utf-8'))
# turned off sub_num += 1
default_sub = index
subtitle_streams_list.append(index)
subtitle_streams.append(track.encode('utf-8'))
sub_num += 1
if audio_numb > 1: if audio_numb > 1:
resp = utils.dialog('select', utils.lang(33013), audio_streams) resp = utils.dialog('select', utils.lang(33013), audio_streams)
@ -418,30 +416,23 @@ def audio_subtitle_prefs(api, listitem):
action_type='PUT', action_type='PUT',
parameters=args) parameters=args)
if sub_num == 1: LOG.debug('Adding downloadable subtitles: %s', download_subs)
# No subtitles
return
select_subs_index = None
if (utils.settings('pickPlexSubtitles') == 'true' and
default_sub is not None):
LOG.info('Using default Plex subtitle: %s', default_sub)
select_subs_index = default_sub
else:
resp = utils.dialog('select', utils.lang(33014), subtitle_streams)
if resp > 0:
select_subs_index = subtitle_streams_list[resp - 1]
else:
# User selected no subtitles or backed out of dialog
select_subs_index = ''
LOG.debug('Adding external subtitles: %s', download_subs)
# Enable Kodi to switch autonomously to downloadable subtitles # Enable Kodi to switch autonomously to downloadable subtitles
if download_subs: if download_subs:
listitem.setSubtitles(download_subs) listitem.setSubtitles(download_subs)
# Don't additionally burn in subtitles if sub_num == 1:
if select_subs_index in downloadable_streams: LOG.debug('No subtitles to burn-in')
select_subs_index = '' return
resp = utils.dialog('select', utils.lang(33014), subtitle_streams)
if resp < 1:
# User did not select a subtitle or backed out of the dialog
LOG.debug('User chose to not burn-in any subtitles')
return
select_subs_index = subtitle_streams_list[resp - 1]
LOG.debug('User chose to burn-in subtitle %s: %s',
select_subs_index,
subtitle_streams[resp].decode('utf-8'))
# Now prep the PMS for our choice # Now prep the PMS for our choice
args = { args = {
'subtitleStreamID': select_subs_index, 'subtitleStreamID': select_subs_index,

View file

@ -107,7 +107,6 @@
<setting id="enableCinema" type="bool" label="30518" default="false" /> <setting id="enableCinema" type="bool" label="30518" default="false" />
<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="resumeJumpBack" type="slider" label="30521" default="10" range="0,1,120" option="int" visible="false"/> <setting id="resumeJumpBack" type="slider" label="30521" default="10" range="0,1,120" option="int" visible="false"/>
<setting type="sep" /> <setting type="sep" />