Fix variable styles

This commit is contained in:
1hitsong 2024-01-04 20:32:09 -05:00
parent 7c8719cbf9
commit 497615e214

View File

@ -230,14 +230,14 @@ end sub
' defaultSubtitleTrackFromVid: Identifies the default subtitle track given video id
'
' @param {dynamic} video_id - id of video user is playing
' @param {dynamic} videoID - id of video user is playing
' @return {integer} indicating the default track's server-side index. Defaults to {SubtitleSelection.none} is one is not found
function defaultSubtitleTrackFromVid(video_id) as integer
function defaultSubtitleTrackFromVid(videoID) as integer
if m.global.session.user.configuration.SubtitleMode = "None"
return SubtitleSelection.none ' No subtitles desired: return none
end if
meta = ItemMetaData(video_id)
meta = ItemMetaData(videoID)
if not isValid(meta) then return SubtitleSelection.none
if not isValid(meta.json) then return SubtitleSelection.none
@ -246,9 +246,9 @@ function defaultSubtitleTrackFromVid(video_id) as integer
subtitles = sortSubtitles(meta.id, meta.json.MediaSources[0].MediaStreams)
default_text_subs = defaultSubtitleTrack(subtitles["all"], true) ' Find correct subtitle track (forced text)
if default_text_subs <> SubtitleSelection.none
return default_text_subs
defaultTextSubs = defaultSubtitleTrack(subtitles["all"], true) ' Find correct subtitle track (forced text)
if defaultTextSubs <> SubtitleSelection.none
return defaultTextSubs
end if
if not m.global.session.user.settings["playback.subs.onlytext"]
@ -260,16 +260,15 @@ end function
' defaultSubtitleTrack:
'
' @param {dynamic} sorted_subtitles - array of subtitles sorted by type and language
' @param {boolean} [require_text=false] - indicates if only text subtitles should be considered
' @param {dynamic} sortedSubtitles - array of subtitles sorted by type and language
' @param {boolean} [requireText=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
function defaultSubtitleTrack(sortedSubtitles, requireText = false as boolean) as integer
userConfig = m.global.session.user.configuration
subtitlePlaybackMode = isValid(userConfig.SubtitlePlaybackMode) ? LCase(userConfig.SubtitlePlaybackMode) : ""
subtitleMode = isValid(userConfig.SubtitleMode) ? LCase(userConfig.SubtitleMode) : ""
for each item in sorted_subtitles
for each item in sortedSubtitles
' Only auto-select subtitle if language matches SubtitleLanguagePreference
languageMatch = true
if userConfig.SubtitleLanguagePreference <> ""
@ -277,7 +276,7 @@ function defaultSubtitleTrack(sorted_subtitles, require_text = false as boolean)
end if
' Ensure textuality of subtitle matches preferenced passed as arg
matchTextReq = ((require_text and item.IsTextSubtitleStream) or not require_text)
matchTextReq = ((requireText and item.IsTextSubtitleStream) or not requireText)
if languageMatch and matchTextReq
if subtitleMode = "default" and (item.isForced or item.IsDefault or item.IsExternal)
@ -286,7 +285,7 @@ function defaultSubtitleTrack(sorted_subtitles, require_text = false as boolean)
return item.Index ' Select the first non-forced subtitle option in the sorted list
else if subtitleMode = "onlyforced" and item.IsForced
return item.Index ' Select the first forced subtitle option in the sorted list
else if subtitlePlaybackMode = "smart" and (item.isForced or item.IsDefault or item.IsExternal)
else if subtitleMode = "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