mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Add transcode dialog skip option: "Media default"
This commit is contained in:
parent
f3c2f1a7a5
commit
ea97b42a52
4 changed files with 71 additions and 41 deletions
|
@ -3,6 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
import enum
|
||||||
import os
|
import os
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
|
@ -17,6 +18,12 @@ from . import translate, settings, window, dialog, api
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
LOG = LazyLogger(__name__)
|
LOG = LazyLogger(__name__)
|
||||||
|
class Transcode(enum.IntEnum):
|
||||||
|
Enabled = 0
|
||||||
|
Audio = 1
|
||||||
|
Subtitle = 2
|
||||||
|
Disabled = 3
|
||||||
|
MediaDefault = 4
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
@ -234,7 +241,7 @@ class PlayUtils(object):
|
||||||
# manual bitrate
|
# manual bitrate
|
||||||
url_parsed = [p for p in url_parsed if 'AudioBitrate' not in p and 'VideoBitrate' not in p]
|
url_parsed = [p for p in url_parsed if 'AudioBitrate' not in p and 'VideoBitrate' not in p]
|
||||||
|
|
||||||
if settings('skipDialogTranscode') != "3" and source.get('MediaStreams'):
|
if settings('skipDialogTranscode') != Transcode.Enabled and source.get('MediaStreams'):
|
||||||
# manual tracks
|
# manual tracks
|
||||||
url_parsed = [p for p in url_parsed if 'AudioStreamIndex' not in p and 'SubtitleStreamIndex' not in p]
|
url_parsed = [p for p in url_parsed if 'AudioStreamIndex' not in p and 'SubtitleStreamIndex' not in p]
|
||||||
manual_tracks = self.get_audio_subs(source, audio, subtitle)
|
manual_tracks = self.get_audio_subs(source, audio, subtitle)
|
||||||
|
@ -598,61 +605,76 @@ class PlayUtils(object):
|
||||||
|
|
||||||
subs_streams.append(index)
|
subs_streams.append(index)
|
||||||
|
|
||||||
skip_dialog = int(settings('skipDialogTranscode') or 0)
|
skip_dialog = Transcode(int(settings('skipDialogTranscode') or 0))
|
||||||
audio_selected = None
|
|
||||||
|
|
||||||
def get_track_title(track_index):
|
def get_track_title(track_index):
|
||||||
return streams[track_index]['DisplayTitle'] or ("Track %s" % track_index)
|
return streams[track_index]['DisplayTitle'] or ("Track %s" % track_index)
|
||||||
|
|
||||||
if audio:
|
# Select audio stream
|
||||||
|
audio_selected = None
|
||||||
|
|
||||||
|
if skip_dialog == Transcode.MediaDefault:
|
||||||
|
# NOTE: "DefaultAudioStreamIndex" is the default according to Jellyfin.
|
||||||
|
# The media's default is marked by the "IsDefault" value.
|
||||||
|
for track_index in audio_streams:
|
||||||
|
if streams[track_index]['IsDefault']:
|
||||||
|
audio = track_index
|
||||||
|
break
|
||||||
|
|
||||||
|
# Compare to None in the off-chance the track index is 0.
|
||||||
|
if audio is not None:
|
||||||
audio_selected = audio
|
audio_selected = audio
|
||||||
|
|
||||||
elif skip_dialog in (0, 1):
|
elif skip_dialog in (Transcode.Enabled, Transcode.Audio):
|
||||||
if len(audio_streams) > 1:
|
if len(audio_streams) > 1:
|
||||||
|
|
||||||
selection = list(map(get_track_title, audio_streams))
|
selection = list(map(get_track_title, audio_streams))
|
||||||
resp = dialog("select", translate(33013), selection)
|
resp = dialog("select", translate(33013), selection)
|
||||||
audio_selected = audio_streams[resp] if resp > -1 else source['DefaultAudioStreamIndex']
|
if resp > -1:
|
||||||
elif len(audio_streams) > 0: # Only one choice
|
audio_selected = audio_streams[resp]
|
||||||
|
else:
|
||||||
|
audio_selected = source['DefaultAudioStreamIndex']
|
||||||
|
elif audio_streams:
|
||||||
|
# Only one choice
|
||||||
audio_selected = audio_streams[0]
|
audio_selected = audio_streams[0]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
audio_selected = source['DefaultAudioStreamIndex']
|
audio_selected = source['DefaultAudioStreamIndex']
|
||||||
|
|
||||||
|
if audio_selected is not None:
|
||||||
self.info['AudioStreamIndex'] = audio_selected
|
self.info['AudioStreamIndex'] = audio_selected
|
||||||
prefs += "&AudioStreamIndex=%s" % audio_selected
|
prefs += "&AudioStreamIndex=%s" % audio_selected
|
||||||
|
|
||||||
if subtitle:
|
# Select audio stream
|
||||||
|
subtitle_selected = None
|
||||||
|
|
||||||
index = subtitle
|
if skip_dialog == Transcode.MediaDefault:
|
||||||
server_settings = self.api_client.get_transcode_settings()
|
for track_index in subs_streams:
|
||||||
stream = streams[index]
|
if streams[track_index]['IsDefault']:
|
||||||
|
subtitle = track_index
|
||||||
|
break
|
||||||
|
|
||||||
if server_settings['EnableSubtitleExtraction'] and stream['SupportsExternalStream']:
|
if subtitle is not None:
|
||||||
self.info['SubtitleUrl'] = self.get_subtitles(source, stream, index)
|
subtitle_selected = subtitle
|
||||||
self.info['SubtitleStreamIndex'] = index
|
|
||||||
elif allow_burned_subs:
|
|
||||||
prefs += "&SubtitleStreamIndex=%s" % index
|
|
||||||
self.info['SubtitleStreamIndex'] = index
|
|
||||||
|
|
||||||
elif skip_dialog in (0, 2) and len(subs_streams):
|
|
||||||
|
|
||||||
|
elif skip_dialog in (Transcode.Enabled, Transcode.Subtitle) and subs_streams:
|
||||||
selection = list(['No subtitles']) + list(map(get_track_title, subs_streams))
|
selection = list(['No subtitles']) + list(map(get_track_title, subs_streams))
|
||||||
resp = dialog("select", translate(33014), selection) - 1
|
resp = dialog("select", translate(33014), selection) - 1
|
||||||
|
# Possible responses:
|
||||||
|
# >=0 Subtitle track
|
||||||
|
# -1 No subtitles (Default)
|
||||||
|
# -2 Dialog was cancelled
|
||||||
if resp > -1:
|
if resp > -1:
|
||||||
index = subs_streams[resp]
|
track_index = subs_streams[resp]
|
||||||
|
subtitle_selected = track_index
|
||||||
if index is not None:
|
|
||||||
|
|
||||||
|
if subtitle_selected is not None:
|
||||||
server_settings = self.api_client.get_transcode_settings()
|
server_settings = self.api_client.get_transcode_settings()
|
||||||
stream = streams[index]
|
stream = streams[track_index]
|
||||||
|
|
||||||
if server_settings['EnableSubtitleExtraction'] and stream['SupportsExternalStream']:
|
if server_settings['EnableSubtitleExtraction'] and stream['SupportsExternalStream']:
|
||||||
self.info['SubtitleUrl'] = self.get_subtitles(source, stream, index)
|
self.info['SubtitleUrl'] = self.get_subtitles(source, stream, subtitle_selected)
|
||||||
self.info['SubtitleStreamIndex'] = index
|
self.info['SubtitleStreamIndex'] = subtitle_selected
|
||||||
elif allow_burned_subs:
|
elif allow_burned_subs:
|
||||||
prefs += "&SubtitleStreamIndex=%s" % index
|
prefs += "&SubtitleStreamIndex=%s" % subtitle_selected
|
||||||
self.info['SubtitleStreamIndex'] = index
|
self.info['SubtitleStreamIndex'] = subtitle_selected
|
||||||
|
|
||||||
return prefs
|
return prefs
|
||||||
|
|
||||||
|
|
|
@ -833,6 +833,10 @@ msgctxt "#33159"
|
||||||
msgid "Enable audio/subtitles selection"
|
msgid "Enable audio/subtitles selection"
|
||||||
msgstr "Enable audio/subtitles selection"
|
msgstr "Enable audio/subtitles selection"
|
||||||
|
|
||||||
|
msgctxt "#33163"
|
||||||
|
msgid "Disabled/Media default"
|
||||||
|
msgstr "Disabled/Media default"
|
||||||
|
|
||||||
msgctxt "#33160"
|
msgctxt "#33160"
|
||||||
msgid "To avoid errors, please update Jellyfin for Kodi to version: "
|
msgid "To avoid errors, please update Jellyfin for Kodi to version: "
|
||||||
msgstr "To avoid errors, please update Jellyfin for Kodi to version: "
|
msgstr "To avoid errors, please update Jellyfin for Kodi to version: "
|
||||||
|
|
|
@ -797,6 +797,10 @@ msgctxt "#33159"
|
||||||
msgid "Enable audio/subtitles selection"
|
msgid "Enable audio/subtitles selection"
|
||||||
msgstr "Enable audio/subtitles selection"
|
msgstr "Enable audio/subtitles selection"
|
||||||
|
|
||||||
|
msgctxt "#33163"
|
||||||
|
msgid "Disabled/Media default"
|
||||||
|
msgstr "Disabled/Media default"
|
||||||
|
|
||||||
msgctxt "#33160"
|
msgctxt "#33160"
|
||||||
msgid "To avoid errors, please update Jellyfin for Kodi to version: "
|
msgid "To avoid errors, please update Jellyfin for Kodi to version: "
|
||||||
msgstr "To avoid errors, please update Jellyfin for Kodi to version: "
|
msgstr "To avoid errors, please update Jellyfin for Kodi to version: "
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
<setting label="30162" id="audioPreferredCodec" type="select" values="AAC|AC3|MP3|Opus|FLAC|Vorbis" visible="true" default="AAC" />
|
<setting label="30162" id="audioPreferredCodec" type="select" values="AAC|AC3|MP3|Opus|FLAC|Vorbis" visible="true" default="AAC" />
|
||||||
<setting label="30163" id="audioBitrate" type="enum" values="96|128|160|192|256|320|384" visible="true" default="4" />
|
<setting label="30163" id="audioBitrate" type="enum" values="96|128|160|192|256|320|384" visible="true" default="4" />
|
||||||
<setting label="30164" id="audioMaxChannels" type="slider" range="2,1,6" option="int" visible="true" default="6" />
|
<setting label="30164" id="audioMaxChannels" type="slider" range="2,1,6" option="int" visible="true" default="6" />
|
||||||
<setting label="33159" id="skipDialogTranscode" type="enum" lvalues="305|33157|33158|13106" visible="true" default="3" />
|
<setting label="33159" id="skipDialogTranscode" type="enum" lvalues="305|33157|33158|13106|33163" visible="true" default="3" />
|
||||||
<setting label="30165" id="allowBurnedSubs" type="bool" visible="true" enable="true" default="true" />
|
<setting label="30165" id="allowBurnedSubs" type="bool" visible="true" enable="true" default="true" />
|
||||||
|
|
||||||
<setting type="sep" />
|
<setting type="sep" />
|
||||||
|
|
Loading…
Reference in a new issue