2019-03-07 03:14:52 +00:00
|
|
|
sub ShowServerSelect()
|
2019-04-29 16:44:37 +00:00
|
|
|
' Get and Save Jellyfin Server Information
|
2019-03-07 03:14:52 +00:00
|
|
|
port = CreateObject("roMessagePort")
|
|
|
|
screen = CreateObject("roSGScreen")
|
|
|
|
screen.setMessagePort(port)
|
|
|
|
scene = screen.CreateScene("ConfigScene")
|
|
|
|
screen.show()
|
|
|
|
|
2019-03-10 05:28:28 +00:00
|
|
|
themeScene(scene)
|
2019-03-17 17:38:21 +00:00
|
|
|
scene.findNode("prompt").text = "Connect to Server"
|
2019-03-07 03:14:52 +00:00
|
|
|
|
|
|
|
config = scene.findNode("configOptions")
|
2019-03-22 03:27:31 +00:00
|
|
|
server_field = CreateObject("roSGNode", "ConfigData")
|
|
|
|
server_field.label = "Server"
|
|
|
|
server_field.field = "server"
|
|
|
|
server_field.type = "string"
|
2019-07-25 01:35:52 +00:00
|
|
|
if get_setting("server") <> invalid
|
|
|
|
server_field.value = get_setting("server")
|
|
|
|
end if
|
2019-03-22 03:27:31 +00:00
|
|
|
port_field = CreateObject("roSGNode", "ConfigData")
|
|
|
|
port_field.label = "Port"
|
|
|
|
port_field.field = "port"
|
|
|
|
port_field.type = "string"
|
2019-07-25 01:35:52 +00:00
|
|
|
if get_setting("port") <> invalid
|
|
|
|
port_field.value = get_setting("port")
|
|
|
|
end if
|
2019-03-22 03:27:31 +00:00
|
|
|
items = [ server_field, port_field ]
|
2019-03-20 03:23:58 +00:00
|
|
|
config.configItems = items
|
2019-03-07 03:14:52 +00:00
|
|
|
|
|
|
|
button = scene.findNode("submit")
|
|
|
|
button.observeField("buttonSelected", port)
|
|
|
|
|
|
|
|
server_hostname = config.content.getChild(0)
|
|
|
|
server_port = config.content.getChild(1)
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed()
|
|
|
|
return
|
|
|
|
else if type(msg) = "roSGNodeEvent"
|
|
|
|
node = msg.getNode()
|
|
|
|
if node = "submit"
|
|
|
|
set_setting("server", server_hostname.value)
|
|
|
|
set_setting("port", server_port.value)
|
2019-04-27 14:44:14 +00:00
|
|
|
if ServerInfo() = invalid then
|
|
|
|
' Maybe don't unset setting, but offer as a prompt
|
|
|
|
' Server not found, is it online? New values / Retry
|
|
|
|
print "Server not found, is it online? New values / Retry"
|
|
|
|
scene.findNode("alert").text = "Server not found, is it online?"
|
|
|
|
SignOut()
|
2019-07-09 13:57:59 +00:00
|
|
|
else
|
2019-04-27 14:44:14 +00:00
|
|
|
return
|
|
|
|
endif
|
2019-03-07 03:14:52 +00:00
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub ShowSignInSelect()
|
2019-04-29 16:44:37 +00:00
|
|
|
' Get and Save Jellyfin user login credentials
|
2019-03-07 03:14:52 +00:00
|
|
|
port = CreateObject("roMessagePort")
|
|
|
|
screen = CreateObject("roSGScreen")
|
|
|
|
screen.setMessagePort(port)
|
|
|
|
scene = screen.CreateScene("ConfigScene")
|
|
|
|
screen.show()
|
|
|
|
|
2019-03-10 05:28:28 +00:00
|
|
|
themeScene(scene)
|
2019-03-07 03:14:52 +00:00
|
|
|
scene.findNode("prompt").text = "Sign In"
|
|
|
|
|
|
|
|
config = scene.findNode("configOptions")
|
2019-03-22 03:27:31 +00:00
|
|
|
username_field = CreateObject("roSGNode", "ConfigData")
|
|
|
|
username_field.label = "Username"
|
|
|
|
username_field.field = "username"
|
|
|
|
username_field.type = "string"
|
|
|
|
password_field = CreateObject("roSGNode", "ConfigData")
|
|
|
|
password_field.label = "Password"
|
|
|
|
password_field.field = "password"
|
|
|
|
password_field.type = "password"
|
|
|
|
items = [ username_field, password_field ]
|
2019-03-20 03:23:58 +00:00
|
|
|
config.configItems = items
|
2019-03-07 03:14:52 +00:00
|
|
|
|
|
|
|
button = scene.findNode("submit")
|
|
|
|
button.observeField("buttonSelected", port)
|
|
|
|
|
|
|
|
config = scene.findNode("configOptions")
|
|
|
|
|
|
|
|
username = config.content.getChild(0)
|
|
|
|
password = config.content.getChild(1)
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed()
|
|
|
|
return
|
|
|
|
else if type(msg) = "roSGNodeEvent"
|
|
|
|
node = msg.getNode()
|
|
|
|
if node = "submit"
|
|
|
|
' Validate credentials
|
|
|
|
get_token(username.value, password.value)
|
|
|
|
if get_setting("active_user") <> invalid then return
|
|
|
|
print "Login attempt failed..."
|
2019-04-27 14:44:14 +00:00
|
|
|
scene.findNode("alert").text = "Login attempt failed."
|
2019-03-07 03:14:52 +00:00
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
2019-10-12 20:21:34 +00:00
|
|
|
function CreateLibraryScene()
|
2019-04-29 16:44:37 +00:00
|
|
|
' Main screen after logging in. Shows the user's libraries
|
2019-10-12 21:23:44 +00:00
|
|
|
group = CreateObject("roSGNode", "Library")
|
2019-03-10 05:28:28 +00:00
|
|
|
|
2019-03-07 03:14:52 +00:00
|
|
|
libs = LibraryList()
|
|
|
|
|
2019-10-12 21:23:44 +00:00
|
|
|
group.libraries = libs
|
|
|
|
group.observeField("librarySelected", m.port)
|
|
|
|
group.observeField("backPressed", m.port)
|
2019-03-07 03:14:52 +00:00
|
|
|
|
2019-10-12 21:23:44 +00:00
|
|
|
library = group.findNode("LibrarySelect")
|
2019-04-15 00:16:47 +00:00
|
|
|
|
2019-10-12 21:23:44 +00:00
|
|
|
search = group.findNode("search")
|
2019-03-14 21:50:42 +00:00
|
|
|
|
2019-10-12 21:23:44 +00:00
|
|
|
sidepanel = group.findNode("options")
|
2019-03-19 04:17:50 +00:00
|
|
|
new_options = []
|
|
|
|
options_buttons = [
|
2019-03-19 14:11:46 +00:00
|
|
|
{"title": "Change server", "id": "change_server"},
|
2019-04-25 04:15:25 +00:00
|
|
|
{"title": "Sign out", "id": "sign_out"},
|
|
|
|
{"title": "Add User", "id": "add_user"}
|
2019-03-19 04:17:50 +00:00
|
|
|
]
|
|
|
|
for each opt in options_buttons
|
|
|
|
o = CreateObject("roSGNode", "OptionsButton")
|
|
|
|
o.title = opt.title
|
|
|
|
o.id = opt.id
|
2019-04-22 20:07:34 +00:00
|
|
|
new_options.push(o)
|
2019-03-19 04:17:50 +00:00
|
|
|
end for
|
|
|
|
|
2019-04-22 20:07:34 +00:00
|
|
|
' And a profile button
|
|
|
|
user_node = CreateObject("roSGNode", "OptionsData")
|
|
|
|
user_node.id = "active_user"
|
|
|
|
user_node.title = "Profile"
|
|
|
|
user_node.base_title = "Profile"
|
|
|
|
user_options = []
|
|
|
|
for each user in AvailableUsers()
|
|
|
|
user_options.push({display: user.username + "@" + user.server, value: user.id})
|
|
|
|
end for
|
|
|
|
user_node.choices = user_options
|
|
|
|
user_node.value = get_setting("active_user")
|
|
|
|
new_options.push(user_node)
|
|
|
|
|
2019-03-19 04:17:50 +00:00
|
|
|
sidepanel.options = new_options
|
|
|
|
|
2019-10-12 21:23:44 +00:00
|
|
|
return group
|
2019-10-12 20:21:34 +00:00
|
|
|
end function
|
2019-03-07 03:14:52 +00:00
|
|
|
|
2019-10-12 20:21:34 +00:00
|
|
|
function CreateMovieScene(library)
|
|
|
|
group = CreateObject("roSGNode", "Movies")
|
2019-03-07 03:14:52 +00:00
|
|
|
|
2019-10-12 20:21:34 +00:00
|
|
|
group.observeField("backPressed", m.port)
|
|
|
|
group.observeField("movieSelected", m.port)
|
2019-03-13 01:16:12 +00:00
|
|
|
|
2019-03-12 03:49:17 +00:00
|
|
|
page_num = 1
|
2019-10-12 20:21:34 +00:00
|
|
|
page_size = 20
|
|
|
|
sort_order = "Ascending"
|
|
|
|
sort_field = "SortName"
|
2019-03-13 01:16:12 +00:00
|
|
|
|
2019-07-09 13:57:59 +00:00
|
|
|
item_list = ItemList(library.id, {"limit": page_size,
|
2019-03-12 03:49:17 +00:00
|
|
|
"StartIndex": page_size * (page_num - 1),
|
2019-03-13 01:16:12 +00:00
|
|
|
"SortBy": sort_field,
|
2019-04-23 01:25:16 +00:00
|
|
|
"SortOrder": sort_order,
|
|
|
|
"IncludeItemTypes": "Movie"
|
|
|
|
})
|
2019-10-12 20:21:34 +00:00
|
|
|
group.objects = item_list
|
2019-03-07 03:14:52 +00:00
|
|
|
|
2019-10-12 20:21:34 +00:00
|
|
|
return group
|
|
|
|
end function
|
2019-03-07 03:14:52 +00:00
|
|
|
|
2019-10-12 20:21:34 +00:00
|
|
|
function CreateMovieDetails(movie)
|
|
|
|
group = CreateObject("roSGNode", "MovieDetails")
|
2019-03-12 03:49:17 +00:00
|
|
|
|
2019-10-12 20:21:34 +00:00
|
|
|
group.observeField("backPressed", m.port)
|
2019-03-12 03:49:17 +00:00
|
|
|
|
2019-10-12 20:21:34 +00:00
|
|
|
movie = ItemMetaData(movie.id)
|
|
|
|
group.itemContent = movie
|
|
|
|
|
|
|
|
buttons = group.findNode("buttons")
|
|
|
|
for each b in buttons.getChildren(-1, 0)
|
|
|
|
b.observeField("buttonSelected", m.port)
|
2019-03-17 23:07:57 +00:00
|
|
|
end for
|
|
|
|
|
2019-10-12 20:21:34 +00:00
|
|
|
return group
|
|
|
|
end function
|
2019-03-08 03:47:10 +00:00
|
|
|
|
2019-03-12 23:34:51 +00:00
|
|
|
sub ShowTVShowOptions(library)
|
2019-04-29 16:44:37 +00:00
|
|
|
' TV Show List Page
|
2019-10-12 20:21:34 +00:00
|
|
|
port = m.port
|
|
|
|
screen = m.screen
|
2019-03-11 01:03:45 +00:00
|
|
|
scene = screen.CreateScene("TVShows")
|
|
|
|
|
2019-03-12 23:34:51 +00:00
|
|
|
overhang = scene.findNode("overhang")
|
|
|
|
overhang.title = library.name
|
|
|
|
|
2019-03-11 01:03:45 +00:00
|
|
|
themeScene(scene)
|
|
|
|
|
2019-07-09 13:57:59 +00:00
|
|
|
item_grid = scene.findNode("picker")
|
2019-03-13 01:16:12 +00:00
|
|
|
|
|
|
|
page_num = 1
|
2019-07-09 13:57:59 +00:00
|
|
|
page_size = 50
|
2019-03-13 01:16:12 +00:00
|
|
|
|
2019-04-23 03:28:25 +00:00
|
|
|
sort_order = get_user_setting("series_sort_order", "Ascending")
|
|
|
|
sort_field = get_user_setting("series_sort_field", "SortName")
|
2019-03-13 01:16:12 +00:00
|
|
|
|
2019-07-09 13:57:59 +00:00
|
|
|
item_list = ItemList(library.id, {"limit": page_size,
|
2019-03-13 01:16:12 +00:00
|
|
|
"page": page_num,
|
|
|
|
"SortBy": sort_field,
|
|
|
|
"SortOrder": sort_order })
|
2019-07-09 13:57:59 +00:00
|
|
|
item_grid.objects = item_list
|
2019-03-11 01:03:45 +00:00
|
|
|
|
2019-07-31 04:31:48 +00:00
|
|
|
item_grid.observeField("escapeButton", port)
|
2019-07-09 13:57:59 +00:00
|
|
|
item_grid.observeField("itemSelected", port)
|
2019-03-11 01:03:45 +00:00
|
|
|
|
2019-03-13 01:16:12 +00:00
|
|
|
pager = scene.findNode("pager")
|
|
|
|
pager.currentPage = page_num
|
2019-07-09 13:57:59 +00:00
|
|
|
pager.maxPages = item_list.TotalRecordCount / page_size
|
2019-07-13 04:10:54 +00:00
|
|
|
if item_list.TotalRecordCount mod page_size > 0 then pager.maxPages += 1
|
2019-03-13 01:16:12 +00:00
|
|
|
|
|
|
|
pager.observeField("escape", port)
|
|
|
|
pager.observeField("pageSelected", port)
|
|
|
|
|
2019-04-23 03:28:25 +00:00
|
|
|
sidepanel = scene.findNode("options")
|
|
|
|
panel_options = [
|
|
|
|
{"title": "Sort Field",
|
|
|
|
"base_title": "Sort Field",
|
|
|
|
"key": "series_sort_field",
|
|
|
|
"default": "SortName",
|
|
|
|
"values": [
|
|
|
|
{display: "Date Added", value: "DateCreated"},
|
|
|
|
{display: "Release Date", value: "PremiereDate"},
|
|
|
|
{display: "Name", value: "SortName"}
|
|
|
|
]},
|
|
|
|
{"title": "Sort Order",
|
|
|
|
"base_title": "Sort Order",
|
|
|
|
"key": "series_sort_order",
|
|
|
|
"default": "Ascending",
|
|
|
|
"values": [
|
|
|
|
{display: "Descending", value: "Descending"},
|
|
|
|
{display: "Ascending", value: "Ascending"}
|
|
|
|
]}
|
|
|
|
]
|
|
|
|
new_options = []
|
|
|
|
for each opt in panel_options
|
|
|
|
o = CreateObject("roSGNode", "OptionsData")
|
|
|
|
o.title = opt.title
|
|
|
|
o.choices = opt.values
|
|
|
|
o.base_title = opt.base_title
|
|
|
|
o.config_key = opt.key
|
|
|
|
o.value = get_user_setting(opt.key, opt.default)
|
|
|
|
new_options.append([o])
|
|
|
|
end for
|
|
|
|
|
|
|
|
sidepanel.options = new_options
|
|
|
|
sidepanel.observeField("escape", port)
|
|
|
|
|
2019-03-11 01:03:45 +00:00
|
|
|
while true
|
|
|
|
msg = wait(0, port)
|
2019-07-31 04:31:48 +00:00
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
|
|
|
return
|
|
|
|
else if nodeEventQ(msg, "escapeButton")
|
|
|
|
node = msg.getRoSGNode()
|
|
|
|
if node.escapeButton = "down"
|
|
|
|
pager.setFocus(true)
|
|
|
|
pager.getChild(0).setFocus(true)
|
|
|
|
else if node.escapeButton = "options"
|
|
|
|
sidepanel.visible = true
|
|
|
|
sidepanel.findNode("panelList").setFocus(true)
|
|
|
|
end if
|
|
|
|
else if nodeEventQ(msg, "escape") and msg.getNode() = "pager"
|
2019-07-09 13:57:59 +00:00
|
|
|
item_grid.setFocus(true)
|
2019-04-23 03:28:25 +00:00
|
|
|
else if nodeEventQ(msg, "escape") and msg.getNode() = "options"
|
2019-07-09 13:57:59 +00:00
|
|
|
item_grid.setFocus(true)
|
2019-03-13 01:16:12 +00:00
|
|
|
else if nodeEventQ(msg, "pageSelected") and pager.pageSelected <> invalid
|
|
|
|
pager.pageSelected = invalid
|
|
|
|
page_num = int(val(msg.getData().id))
|
|
|
|
pager.currentPage = page_num
|
2019-07-09 13:57:59 +00:00
|
|
|
item_list = ItemList(library.id, {"limit": page_size,
|
2019-03-13 01:16:12 +00:00
|
|
|
"StartIndex": page_size * (page_num - 1),
|
|
|
|
"SortBy": sort_field,
|
|
|
|
"SortOrder": sort_order })
|
2019-07-09 13:57:59 +00:00
|
|
|
item_grid.objects = item_list
|
|
|
|
item_grid.setFocus(true)
|
2019-03-13 01:16:12 +00:00
|
|
|
else if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
2019-03-11 01:03:45 +00:00
|
|
|
return
|
|
|
|
else if nodeEventQ(msg, "itemSelected")
|
|
|
|
target = getMsgRowTarget(msg)
|
2019-04-15 00:16:47 +00:00
|
|
|
ShowTVShowDetails(target)
|
2019-03-11 01:03:45 +00:00
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
2019-04-15 00:16:47 +00:00
|
|
|
sub ShowTVShowDetails(series)
|
2019-04-29 16:44:37 +00:00
|
|
|
' TV Show Detail Page
|
2019-10-12 20:21:34 +00:00
|
|
|
port = m.port
|
|
|
|
screen = m.screen
|
2019-03-11 01:24:50 +00:00
|
|
|
scene = screen.CreateScene("TVShowItemDetailScene")
|
|
|
|
|
|
|
|
themeScene(scene)
|
|
|
|
|
2019-04-15 00:16:47 +00:00
|
|
|
series = ItemMetaData(series.id)
|
|
|
|
scene.itemData = series
|
2019-04-06 06:15:30 +00:00
|
|
|
scene.findNode("description").findNode("buttons").setFocus(true)
|
2019-04-15 00:16:47 +00:00
|
|
|
scene.seasonData = TVSeasons(series.id)
|
2019-03-31 03:15:53 +00:00
|
|
|
|
2019-04-06 06:15:30 +00:00
|
|
|
scene.findNode("description").findNode("buttons").setFocus(true)
|
2019-03-11 01:24:50 +00:00
|
|
|
|
|
|
|
'buttons = scene.findNode("buttons")
|
|
|
|
'buttons.observeField("buttonSelected", port)
|
|
|
|
|
2019-04-14 04:47:27 +00:00
|
|
|
scene.findNode("seasons").observeField("rowItemSelected", port)
|
2019-03-31 03:15:53 +00:00
|
|
|
|
2019-03-11 01:24:50 +00:00
|
|
|
while true
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
|
|
|
return
|
|
|
|
else if nodeEventQ(msg, "buttonSelected")
|
|
|
|
' What button could we even be watching yet
|
2019-04-14 04:47:27 +00:00
|
|
|
else if nodeEventQ(msg, "rowItemSelected")
|
|
|
|
' Assume for now it's a season being selected
|
|
|
|
season_list = msg.getRoSGNode()
|
|
|
|
item = msg.getData()
|
|
|
|
season = season_list.content.getChild(item[0]).getChild(item[1])
|
|
|
|
|
2019-04-15 00:16:47 +00:00
|
|
|
ShowTVSeasonEpisodes(series, season)
|
2019-04-14 04:47:27 +00:00
|
|
|
else
|
|
|
|
print msg
|
|
|
|
print type(msg)
|
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
2019-04-15 00:16:47 +00:00
|
|
|
sub ShowTVSeasonEpisodes(series, season)
|
2019-04-29 16:44:37 +00:00
|
|
|
' TV Show Season Episdoe List
|
2019-10-12 20:21:34 +00:00
|
|
|
port = m.port
|
|
|
|
screen = m.screen
|
2019-04-14 04:47:27 +00:00
|
|
|
scene = screen.CreateScene("TVEpisodes")
|
|
|
|
|
|
|
|
themeScene(scene)
|
|
|
|
|
2019-04-15 00:16:47 +00:00
|
|
|
scene.showData = ItemMetaData(series.id)
|
|
|
|
scene.seasonData = TVSeasons(series.id)
|
|
|
|
scene.episodeData = TVEpisodes(series.id, season.id)
|
2019-04-14 04:47:27 +00:00
|
|
|
|
|
|
|
scene.findNode("TVEpisodeSelect").observeField("rowItemSelected", port)
|
|
|
|
|
|
|
|
while true
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
|
|
|
return
|
|
|
|
else if nodeEventQ(msg, "rowItemSelected")
|
|
|
|
episode_list = msg.getRoSGNode()
|
|
|
|
item = msg.getData()
|
|
|
|
episode = episode_list.content.getChild(item[0]).getChild(item[1])
|
|
|
|
|
2019-04-15 00:16:47 +00:00
|
|
|
ShowVideoPlayer(episode.id)
|
2019-03-11 01:24:50 +00:00
|
|
|
else
|
|
|
|
print msg
|
|
|
|
print type(msg)
|
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
2019-03-20 02:30:08 +00:00
|
|
|
sub ShowCollections(library)
|
2019-04-30 01:47:40 +00:00
|
|
|
' Load Movie Collection Items
|
2019-10-12 20:21:34 +00:00
|
|
|
port = m.port
|
|
|
|
screen = m.screen
|
2019-03-20 02:30:08 +00:00
|
|
|
scene = screen.CreateScene("Collections")
|
|
|
|
|
|
|
|
overhang = scene.findNode("overhang")
|
|
|
|
overhang.title = library.name
|
|
|
|
|
|
|
|
themeScene(scene)
|
|
|
|
|
2019-07-09 13:57:59 +00:00
|
|
|
item_grid = scene.findNode("picker")
|
2019-03-20 02:30:08 +00:00
|
|
|
|
|
|
|
page_num = 1
|
2019-07-09 13:57:59 +00:00
|
|
|
page_size = 50
|
2019-03-20 02:30:08 +00:00
|
|
|
|
|
|
|
sort_order = get_user_setting("collection_sort_order", "Ascending")
|
|
|
|
sort_field = get_user_setting("collection_sort_field", "SortName")
|
|
|
|
|
2019-07-09 13:57:59 +00:00
|
|
|
item_list = ItemList(library.id, {"limit": page_size,
|
2019-03-20 02:30:08 +00:00
|
|
|
"StartIndex": page_size * (page_num - 1),
|
|
|
|
"SortBy": sort_field,
|
|
|
|
"SortOrder": sort_order })
|
2019-07-09 13:57:59 +00:00
|
|
|
item_grid.objects = item_list
|
2019-03-20 02:30:08 +00:00
|
|
|
|
2019-07-31 04:31:48 +00:00
|
|
|
item_grid.observeField("escapeButton", port)
|
2019-07-09 13:57:59 +00:00
|
|
|
item_grid.observeField("itemSelected", port)
|
2019-03-20 02:30:08 +00:00
|
|
|
|
|
|
|
pager = scene.findNode("pager")
|
|
|
|
pager.currentPage = page_num
|
2019-07-09 13:57:59 +00:00
|
|
|
pager.maxPages = item_list.TotalRecordCount / page_size
|
2019-07-13 04:10:54 +00:00
|
|
|
if item_list.TotalRecordCount mod page_size > 0 then pager.maxPages += 1
|
2019-03-20 02:30:08 +00:00
|
|
|
|
|
|
|
pager.observeField("escape", port)
|
|
|
|
pager.observeField("pageSelected", port)
|
|
|
|
|
|
|
|
sidepanel = scene.findNode("options")
|
|
|
|
panel_options = [
|
|
|
|
{"title": "Sort Field",
|
|
|
|
"base_title": "Sort Field",
|
|
|
|
"key": "movie_sort_field",
|
2019-04-23 03:28:25 +00:00
|
|
|
"default": "SortName",
|
2019-04-22 19:08:10 +00:00
|
|
|
"values": [
|
|
|
|
{display: "Date Added", value: "DateCreated"},
|
|
|
|
{display: "Release Date", value: "PremiereDate"},
|
|
|
|
{display: "Name", value: "SortName"}
|
|
|
|
]},
|
2019-03-20 02:30:08 +00:00
|
|
|
{"title": "Sort Order",
|
|
|
|
"base_title": "Sort Order",
|
|
|
|
"key": "movie_sort_order",
|
2019-04-23 03:28:25 +00:00
|
|
|
"default": "Ascending",
|
2019-04-22 19:08:10 +00:00
|
|
|
"values": [
|
|
|
|
{display: "Descending", value: "Descending"},
|
|
|
|
{display: "Ascending", value: "Ascending"}
|
|
|
|
]}
|
2019-03-20 02:30:08 +00:00
|
|
|
]
|
|
|
|
new_options = []
|
|
|
|
for each opt in panel_options
|
|
|
|
o = CreateObject("roSGNode", "OptionsData")
|
|
|
|
o.title = opt.title
|
|
|
|
o.choices = opt.values
|
|
|
|
o.base_title = opt.base_title
|
|
|
|
o.config_key = opt.key
|
|
|
|
o.value = get_user_setting(opt.key, opt.default)
|
|
|
|
new_options.append([o])
|
|
|
|
end for
|
|
|
|
|
|
|
|
sidepanel.options = new_options
|
|
|
|
sidepanel.observeField("escape", port)
|
|
|
|
|
|
|
|
while true
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
|
|
|
return
|
2019-07-31 04:31:48 +00:00
|
|
|
else if nodeEventQ(msg, "escapeButton")
|
|
|
|
node = msg.getRoSGNode()
|
|
|
|
if node.escapeButton = "down"
|
|
|
|
pager.setFocus(true)
|
|
|
|
pager.getChild(0).setFocus(true)
|
|
|
|
else if node.escapeButton = "options"
|
|
|
|
sidepanel.visible = true
|
|
|
|
sidepanel.findNode("panelList").setFocus(true)
|
|
|
|
end if
|
2019-03-20 02:30:08 +00:00
|
|
|
else if nodeEventQ(msg, "escape") and msg.getNode() = "pager"
|
2019-07-09 13:57:59 +00:00
|
|
|
item_grid.setFocus(true)
|
2019-03-20 02:30:08 +00:00
|
|
|
else if nodeEventQ(msg, "escape") and msg.getNode() = "options"
|
2019-07-09 13:57:59 +00:00
|
|
|
item_grid.setFocus(true)
|
2019-03-20 02:30:08 +00:00
|
|
|
else if nodeEventQ(msg, "pageSelected") and pager.pageSelected <> invalid
|
|
|
|
pager.pageSelected = invalid
|
|
|
|
page_num = int(val(msg.getData().id))
|
|
|
|
pager.currentPage = page_num
|
2019-07-09 13:57:59 +00:00
|
|
|
item_list = ItemList(library.id, {"limit": page_size,
|
2019-03-20 02:30:08 +00:00
|
|
|
"StartIndex": page_size * (page_num - 1),
|
2019-06-17 00:02:22 +00:00
|
|
|
"SortBy": sort_field,
|
|
|
|
"SortOrder": sort_order })
|
2019-07-09 13:57:59 +00:00
|
|
|
item_grid.itemData = item_list
|
|
|
|
item_grid.setFocus(true)
|
2019-03-20 02:30:08 +00:00
|
|
|
else if nodeEventQ(msg, "itemSelected")
|
|
|
|
target = getMsgRowTarget(msg)
|
|
|
|
ShowMovieOptions(target)
|
|
|
|
else
|
|
|
|
print msg
|
|
|
|
print msg.getField()
|
|
|
|
print msg.getData()
|
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
2019-03-14 22:50:20 +00:00
|
|
|
sub ShowSearchOptions(query)
|
2019-04-29 16:44:37 +00:00
|
|
|
' Search Results Page
|
2019-10-12 20:21:34 +00:00
|
|
|
port = m.port
|
|
|
|
screen = m.screen
|
2019-03-14 22:50:20 +00:00
|
|
|
scene = screen.CreateScene("SearchResults")
|
|
|
|
|
|
|
|
themeScene(scene)
|
|
|
|
|
|
|
|
options = scene.findNode("SearchSelect")
|
|
|
|
|
2019-04-23 03:28:25 +00:00
|
|
|
sort_order = get_user_setting("search_sort_order", "Ascending")
|
|
|
|
sort_field = get_user_setting("search_sort_field", "SortName")
|
2019-03-14 22:50:20 +00:00
|
|
|
|
|
|
|
results = SearchMedia(query)
|
|
|
|
options.itemData = results
|
|
|
|
options.query = query
|
|
|
|
|
|
|
|
options.observeField("itemSelected", port)
|
|
|
|
|
|
|
|
while true
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
|
|
|
return
|
|
|
|
else if nodeEventQ(msg, "itemSelected")
|
|
|
|
target = getMsgRowTarget(msg)
|
|
|
|
' TODO - swap this based on target.mediatype
|
|
|
|
' types: [ Episode, Movie, Audio, Person, Studio, MusicArtist ]
|
2019-04-15 00:16:47 +00:00
|
|
|
ShowMovieDetails(target)
|
2019-03-14 22:50:20 +00:00
|
|
|
else
|
|
|
|
print msg
|
|
|
|
print msg.getField()
|
|
|
|
print msg.getData()
|
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
2019-10-12 21:00:07 +00:00
|
|
|
function CreateVideoPlayer(video_id)
|
2019-04-29 16:44:37 +00:00
|
|
|
' Video is Playing
|
2019-03-19 00:33:44 +00:00
|
|
|
video = VideoPlayer(video_id)
|
|
|
|
|
2019-10-12 21:00:07 +00:00
|
|
|
video.observeField("backPressed", m.port)
|
|
|
|
video.observeField("state", m.port)
|
2019-03-07 03:14:52 +00:00
|
|
|
|
2019-10-12 21:00:07 +00:00
|
|
|
return video
|
|
|
|
end function
|