Working for Episodes from Home Screen.

This commit is contained in:
Jimi 2023-05-06 14:34:17 -06:00
parent 910ce95214
commit 1c33a96439
2 changed files with 25 additions and 0 deletions

View File

@ -122,6 +122,10 @@ sub Main (args as dynamic) as void
if itemNode.type = "Episode" or itemNode.type = "Movie" or itemNode.type = "Video"
if itemNode.type = "Episode" and itemNode.selectedAudioStreamIndex <> invalid and itemNode.selectedAudioStreamIndex > 1
video = CreateVideoPlayerGroup(itemNode.id, invalid, itemNode.selectedAudioStreamIndex)
else if get_user_setting("display.playback.AudioLanguagePreference") <> invalid
langPreference = get_user_setting("display.playback.AudioLanguagePreference")
preferredLang = FindPreferredAudioStream(itemNode.json.MediaStreams, langPreference)
video = CreateVideoPlayerGroup(itemNode.id, invalid, preferredLang)
else
video = CreateVideoPlayerGroup(itemNode.id)
end if
@ -610,3 +614,15 @@ sub Main (args as dynamic) as void
end while
end sub
function FindPreferredAudioStream(streams, preferredLanguage)
for i = 0 to streams.Count() - 1
if streams[i].Type = "Audio" and streams[i].Language = preferredLanguage
return i
end if
end for
return 0
end function

View File

@ -146,6 +146,15 @@ sub LoadUserPreferences()
else
unset_user_setting("display.livetv.landing")
end if
' Get users custom configuration
resp = APIRequest("Users/Me")
jsonResponse = getJson(resp)
if jsonResponse <> invalid and jsonResponse.Configuration <> invalid and jsonResponse.Configuration["AudioLanguagePreference"] <> invalid
set_user_setting("display.playback.AudioLanguagePreference", jsonResponse.Configuration["AudioLanguagePreference"])
else
unset_user_setting("display.playback.AudioLanguagePreference")
end if
end sub
sub LoadUserAbilities(user)