Tweaking audio subs pref some more

This commit is contained in:
angelblue05 2015-06-08 20:19:56 -05:00
parent ad6626c086
commit 3fcdbe0bb8

View file

@ -249,94 +249,102 @@ class Player( xbmc.Player ):
defaultsubs = WINDOW.getProperty("%ssubs" % currentFile) defaultsubs = WINDOW.getProperty("%ssubs" % currentFile)
codecs = [ codecs = [
# To be adjusted and include every codec Emby server can return. # Possible codecs
'und','Stereo','Stereo - Stereo','AC3 5.1' 'und','Stereo','AC3','DTS', '5.1',
#'Stereo - Stereo','AC3 5.1', 'DTS 5.1', 'DTS-HD MA 5.1'
] ]
if len(audiotracks) == 1 and len(subs) == 0: if len(audiotracks) == 1 and len(subs) == 0:
# There's only one audio track and no subtitles # There's only one audio track and no subtitles
xbmcplayer.showSubtitles(False) xbmcplayer.showSubtitles(False)
elif self.audioPref in audiotracks: else:
self.logMsg("Door 1", 2) # More complex cases
# Audio pref is available codec_intrack = False
index = audiotracks.index(self.audioPref) for codec in codecs:
xbmcplayer.setAudioStream(index) if codec in '\n'.join(audiotracks):
codec_intrack = True
if addon.getSetting('subsoverride') == "true": if self.audioPref in audiotracks:
self.logMsg("Door 1", 1)
# Audio pref is available
index = audiotracks.index(self.audioPref)
xbmcplayer.setAudioStream(index)
if addon.getSetting('subsoverride') == "true":
if self.subsPref in subs:
self.logMsg("Door 1.1", 1)
# Subs are forced.
index = subs.index(self.subsPref)
xbmcplayer.setSubtitleStream(index)
else:
# Use default subs
if defaultsubs == "ssa":
# For some reason, Kodi sees SSA as ''
self.logMsg("Door 1.2", 1)
index = subs.index('')
xbmcplayer.setSubtitleStream(index)
elif defaultsubs:
self.logMsg("Door 1.3", 1)
index = subs.index(defaultsubs)
xbmcplayer.setSubtitleStream(index)
else:
xbmcplayer.showSubtitles(False)
elif (len(audiotracks) == 1) and not codec_intrack:
self.logMsg("Door 2", 1)
# 1. There's one audio track.
# 2. The audio is defined as a language.
# 3. Audio pref is not available, guaranteed.
if self.subsPref in subs: if self.subsPref in subs:
self.logMsg("Door 1.1", 2) self.logMsg("Door 2.1", 1)
# Subs are forced. # Subs pref is available.
index = subs.index(self.subsPref) index = subs.index(self.subsPref)
xbmcplayer.setSubtitleStream(index) xbmcplayer.setSubtitleStream(index)
else: else:
# Use default subs # Use default subs
if defaultsubs == "ssa": if defaultsubs == "ssa":
# For some reason, Kodi sees SSA as '' # For some reason, Kodi sees SSA as ''
self.logMsg("Door 1.2", 2) self.logMsg("Door 2.2", 1)
index = subs.index('') index = subs.index('')
xbmcplayer.setSubtitleStream(index) xbmcplayer.setSubtitleStream(index)
elif defaultsubs: elif defaultsubs:
self.logMsg("Door 1.3", 2) self.logMsg("Door 2.3", 1)
index = subs.index(defaultsubs) index = subs.index(defaultsubs)
xbmcplayer.setSubtitleStream(index) xbmcplayer.setSubtitleStream(index)
else:
xbmcplayer.showSubtitles(False)
elif len(audiotracks) == 1 and '\n'.join(audiotracks) not in codecs: elif len(audiotracks) == 1 and codec_intrack:
self.logMsg("Door 2", 2) self.logMsg("Door 3", 1)
# 1. There's one audio track. # 1. There one audio track.
# 2. The audio is defined as a language. # 2. The audio is undefined or a codec.
# 3. Audio pref is not available, guaranteed. # 3. Audio track is mislabeled.
if self.subsPref in subs: if self.subsPref in subs:
self.logMsg("Door 2.1", 2) # If the subtitle is available, only display
# Subs pref is available. # if the setting is enabled.
index = subs.index(self.subsPref) if addon.getSetting('subsoverride') == "true":
xbmcplayer.setSubtitleStream(index) # Subs are forced.
else: self.logMsg("Door 3.2", 1)
# Use default subs index = subs.index(self.subsPref)
if defaultsubs == "ssa": xbmcplayer.setSubtitleStream(index)
# For some reason, Kodi sees SSA as '' else:
self.logMsg("Door 2.2", 2) # Let the user decide, since track is mislabeled.
index = subs.index('') self.logMsg("Door 3.3")
xbmcplayer.setSubtitleStream(index) xbmcplayer.showSubtitles(False)
elif defaultsubs:
self.logMsg("Door 2.3", 2)
index = subs.index(defaultsubs)
xbmcplayer.setSubtitleStream(index)
elif len(audiotracks) == 1 and '\n'.join(audiotracks) in codecs:
self.logMsg("Door 3", 2)
# 1. There one audio track.
# 2. The audio is undefined or a codec.
# 3. Audio track is be mislabeled.
if self.subsPref in subs:
# If the subtitle is available, only display
# if the setting is enabled.
if addon.getSetting('subsoverride') == "true":
# Subs are forced.
self.logMsg("Door 3.2", 2)
index = subs.index(self.subsPref)
xbmcplayer.setSubtitleStream(index)
else: else:
# Let the user decide, since track is mislabeled. # Use default subs
self.logMsg("Door 3.3") if defaultsubs == "ssa":
xbmcplayer.showSubtitles(False) # For some reason, Kodi sees SSA as ''
else: self.logMsg("Door 3.4", 1)
# Use default subs index = subs.index('')
if defaultsubs == "ssa": xbmcplayer.setSubtitleStream(index)
# For some reason, Kodi sees SSA as '' elif defaultsubs:
self.logMsg("Door 3.4", 2) self.logMsg("Door 3.5", 1)
index = subs.index('') index = subs.index(defaultsubs)
xbmcplayer.setSubtitleStream(index) xbmcplayer.setSubtitleStream(index)
elif defaultsubs: else:
self.logMsg("Door 3.5", 2) # Nothing matches, let the user decide.
index = subs.index(defaultsubs) self.logMsg("Door 3.6", 1)
xbmcplayer.setSubtitleStream(index) xbmcplayer.showSubtitles(False)
else:
# Nothing matches, let the user decide.
self.logMsg("Door 3.6", 2)
xbmcplayer.showSubtitles(False)
# we may need to wait until the info is available # we may need to wait until the info is available
item_id = WINDOW.getProperty(currentFile + "item_id") item_id = WINDOW.getProperty(currentFile + "item_id")