diff --git a/components/data/movie.xml b/components/data/movie.xml index 67145e43..918969fd 100644 --- a/components/data/movie.xml +++ b/components/data/movie.xml @@ -8,24 +8,48 @@ + diff --git a/components/data/options-choices.xml b/components/data/options-choices.xml index 09bfa676..6e35736b 100644 --- a/components/data/options-choices.xml +++ b/components/data/options-choices.xml @@ -2,7 +2,7 @@ - + @@ -17,12 +17,12 @@ sub update_title() for i=0 to m.top.choices.count() - 1 - if m.top.choices[i] = m.top.value + if m.top.choices[i].value = m.top.value m.top.value_index = i exit for end if end for - m.top.title = m.top.base_title + ": " + m.top.value + m.top.title = m.top.base_title + ": " + m.top.choices[m.top.value_index].display end sub sub press() @@ -33,7 +33,7 @@ end while m.top.value_index = i - m.top.value = m.top.choices[m.top.value_index] + m.top.value = m.top.choices[m.top.value_index].value set_user_setting(m.top.config_key, m.top.value) end sub diff --git a/components/data/user.xml b/components/data/user.xml index fdfc6f94..8082382a 100644 --- a/components/data/user.xml +++ b/components/data/user.xml @@ -4,7 +4,10 @@ + + + @@ -36,6 +39,22 @@ function saveToRegistry() set_user_setting("username", m.top.username) set_user_setting("token", m.top.token) + + users = get_setting("available_users", {}) + this_user = invalid + for each user in users + if user.id = m.top.id then this_user = user + end for + if this_user = invalid + users[m.top.id] = { + id: m.top.id, + username: m.top.username, + server: get_setting("server"), + port: get_setting("port") + } + set_setting("available_users", users) + end if + end function function getPreference(key as String, default as String) @@ -49,6 +68,11 @@ function setActive() set_setting("active_user", m.top.id) end function + + function setServer(hostname as string, port as string) + m.top.server = hostname + m.top.port = port + end function ]]> diff --git a/source/Main.brs b/source/Main.brs index df79e6ed..0578d437 100644 --- a/source/Main.brs +++ b/source/Main.brs @@ -2,8 +2,20 @@ sub Main() keepalive = CreateObject("roSGScreen") keepalive.show() + app_start: ' First thing to do is validate the ability to use the API + LoginFlow() + ' Confirm the configured server and user work + ShowLibrarySelect() + + ' Have a catch for exiting the library on sign-out + if get_setting("active_user") = invalid + goto app_start + end if +end sub + +sub LoginFlow() start_login: if get_setting("server") = invalid then print "Get server details" @@ -14,8 +26,8 @@ sub Main() ' Maybe don't unset setting, but offer as a prompt ' Server not found, is it online? New values / Retry print "Connection to server failed, restart flow" + SignOut() unset_setting("server") - unset_setting("active_user") goto start_login end if @@ -24,17 +36,10 @@ sub Main() ShowSigninSelect() end if - ' Confirm the configured server and user work m.user = AboutMe() if m.user = invalid or m.user.id <> get_setting("active_user") print "Login failed, restart flow" unset_setting("active_user") goto start_login end if - - ShowLibrarySelect() - - if get_setting("active_user") = invalid - goto start_login - end if end sub diff --git a/source/ShowScenes.brs b/source/ShowScenes.brs index 9374ce89..4c6400ce 100644 --- a/source/ShowScenes.brs +++ b/source/ShowScenes.brs @@ -213,12 +213,19 @@ sub ShowMovieOptions(library) "base_title": "Sort Field", "key": "movie_sort_field", "default": "DateCreated", - "values": ["DateCreated", "PremiereDate", "SortName"]}, + "values": [ + {display: "Date Added", value: "DateCreated"}, + {display: "Release Date", value: "PremiereDate"}, + {display: "Name", value: "SortName"} + ]}, {"title": "Sort Order", "base_title": "Sort Order", "key": "movie_sort_order", "default": "Descending", - "values": ["Descending", "Ascending"]} + "values": [ + {display: "Descending", value: "Descending"}, + {display: "Ascending", value: "Ascending"} + ]} ] new_options = [] for each opt in movie_options @@ -490,12 +497,19 @@ sub ShowCollections(library) "base_title": "Sort Field", "key": "movie_sort_field", "default": "DateCreated", - "values": ["DateCreated", "PremiereDate", "SortName"]}, + "values": [ + {display: "Date Added", value: "DateCreated"}, + {display: "Release Date", value: "PremiereDate"}, + {display: "Name", value: "SortName"} + ]}, {"title": "Sort Order", "base_title": "Sort Order", "key": "movie_sort_order", "default": "Descending", - "values": ["Descending", "Ascending"]} + "values": [ + {display: "Descending", value: "Descending"}, + {display: "Ascending", value: "Ascending"} + ]} ] new_options = [] for each opt in panel_options diff --git a/source/VideoPlayer.brs b/source/VideoPlayer.brs index 2541fa9d..a6585b59 100644 --- a/source/VideoPlayer.brs +++ b/source/VideoPlayer.brs @@ -45,8 +45,10 @@ function VideoContent(id) as object end function function getContainerType(meta as object) as string + print type(meta) if meta.json.mediaSources = invalid then return "" + container = meta.json.mediaSources[0].container if container = invalid container = "" diff --git a/source/api/userauth.brs b/source/api/userauth.brs index f9122bdc..db0bf1a9 100644 --- a/source/api/userauth.brs +++ b/source/api/userauth.brs @@ -22,10 +22,21 @@ function AboutMe() end function function SignOut() - unset_user_setting("token") + if get_setting("active_user") <> invalid + unset_user_setting("token") + end if unset_setting("active_user") end function +function AvailableUsers() + users = get_setting("available_users", {}) + return users +end function + +function PickUser(id as string) + + +end function function ServerInfo() url = "System/Info/Public"