Code cleanup
This commit is contained in:
parent
3a9987f29c
commit
286749ce4c
|
@ -264,24 +264,27 @@ end function
|
|||
' @param {boolean} [require_text=false] - indicates if only text subtitles should be considered
|
||||
' @return {integer} indicating the default track's server-side index. Defaults to {SubtitleSelection.none} is one is not found
|
||||
function defaultSubtitleTrack(sorted_subtitles, require_text = false as boolean) as integer
|
||||
userConfig = m.global.session.user.configuration
|
||||
subtitleMode = LCase(userConfig.SubtitleMode)
|
||||
|
||||
for each item in sorted_subtitles
|
||||
' Only auto-select subtitle if language matches SubtitleLanguagePreference
|
||||
languageMatch = true
|
||||
if m.global.session.user.configuration.SubtitleLanguagePreference <> ""
|
||||
languageMatch = (m.global.session.user.configuration.SubtitleLanguagePreference = item.Track.Language)
|
||||
if userConfig.SubtitleLanguagePreference <> ""
|
||||
languageMatch = (userConfig.SubtitleLanguagePreference = item.Track.Language)
|
||||
end if
|
||||
|
||||
' Ensure textuality of subtitle matches preferenced passed as arg
|
||||
matchTextReq = ((require_text and item.IsTextSubtitleStream) or not require_text)
|
||||
|
||||
if languageMatch and matchTextReq
|
||||
if m.global.session.user.configuration.SubtitleMode = "Default" and (item.isForced or item.IsDefault or item.IsExternal)
|
||||
if subtitleMode = "default" and (item.isForced or item.IsDefault or item.IsExternal)
|
||||
return item.Index ' Finds first forced, or default, or external subs in sorted list
|
||||
else if m.global.session.user.configuration.SubtitleMode = "Always" and not item.IsForced
|
||||
else if subtitleMode = "always" and not item.IsForced
|
||||
return item.Index ' Select the first non-forced subtitle option in the sorted list
|
||||
else if m.global.session.user.configuration.SubtitleMode = "OnlyForced" and item.IsForced
|
||||
else if subtitleMode = "onlyforced" and item.IsForced
|
||||
return item.Index ' Select the first forced subtitle option in the sorted list
|
||||
else if m.global.session.user.configuration.SubtitlePlaybackMode = "Smart" and (item.isForced or item.IsDefault or item.IsExternal)
|
||||
else if LCase(userConfig.SubtitlePlaybackMode) = "smart" and (item.isForced or item.IsDefault or item.IsExternal)
|
||||
' Simplified "Smart" logic here mimics Default (as that is fallback behavior normally)
|
||||
' Avoids detecting preferred audio language (as is utilized in main client)
|
||||
return item.Index
|
||||
|
|
Loading…
Reference in New Issue
Block a user