2020-03-12 18:33:45 +00:00
|
|
|
sub init()
|
2020-03-24 07:37:45 +00:00
|
|
|
m.top.functionName = "loadItems"
|
2020-03-12 18:33:45 +00:00
|
|
|
end sub
|
|
|
|
|
|
|
|
sub loadItems()
|
|
|
|
|
2020-03-24 07:37:45 +00:00
|
|
|
results = []
|
2020-03-12 18:33:45 +00:00
|
|
|
|
2020-03-24 07:37:45 +00:00
|
|
|
' Load Libraries
|
|
|
|
if m.top.itemsToLoad = "libraries"
|
2020-03-12 18:33:45 +00:00
|
|
|
|
2020-03-24 07:37:45 +00:00
|
|
|
url = Substitute("Users/{0}/Views/", get_setting("active_user"))
|
|
|
|
resp = APIRequest(url)
|
|
|
|
data = getJson(resp)
|
|
|
|
for each item in data.Items
|
|
|
|
tmp = CreateObject("roSGNode", "HomeData")
|
|
|
|
tmp.json = item
|
|
|
|
results.push(tmp)
|
|
|
|
end for
|
2020-03-12 18:33:45 +00:00
|
|
|
|
|
|
|
' Load Latest Additions to Libraries
|
2020-03-24 07:37:45 +00:00
|
|
|
else if m.top.itemsToLoad = "latest"
|
2020-03-12 18:33:45 +00:00
|
|
|
|
2020-03-24 07:37:45 +00:00
|
|
|
url = Substitute("Users/{0}/Items/Latest", get_setting("active_user"))
|
|
|
|
params = {}
|
|
|
|
params["Limit"] = 16
|
|
|
|
params["ParentId"] = m.top.itemId
|
|
|
|
params["EnableImageTypes"] = "Primary,Backdrop,Thumb"
|
|
|
|
params["ImageTypeLimit"] = 1
|
2020-03-12 18:33:45 +00:00
|
|
|
|
2020-03-24 07:37:45 +00:00
|
|
|
resp = APIRequest(url, params)
|
|
|
|
data = getJson(resp)
|
2020-03-12 18:33:45 +00:00
|
|
|
|
2020-03-24 07:37:45 +00:00
|
|
|
for each item in data
|
|
|
|
tmp = CreateObject("roSGNode", "HomeData")
|
|
|
|
tmp.json = item
|
|
|
|
results.push(tmp)
|
|
|
|
end for
|
2020-03-12 18:33:45 +00:00
|
|
|
|
|
|
|
' Load Next Up
|
2020-03-24 07:37:45 +00:00
|
|
|
else if m.top.itemsToLoad = "nextUp"
|
|
|
|
|
|
|
|
url = "Shows/NextUp"
|
|
|
|
params = {}
|
|
|
|
params["recursive"] = true
|
|
|
|
params["SortBy"] = "DatePlayed"
|
|
|
|
params["SortOrder"] = "Descending"
|
|
|
|
params["ImageTypeLimit"] = 1
|
|
|
|
params["UserId"] = get_setting("active_user")
|
|
|
|
|
|
|
|
resp = APIRequest(url, params)
|
|
|
|
data = getJson(resp)
|
|
|
|
for each item in data.Items
|
|
|
|
tmp = CreateObject("roSGNode", "HomeData")
|
|
|
|
tmp.json = item
|
|
|
|
results.push(tmp)
|
|
|
|
end for
|
|
|
|
|
|
|
|
' Load Continue Watching
|
|
|
|
else if m.top.itemsToLoad = "continue"
|
|
|
|
|
|
|
|
url = Substitute("Users/{0}/Items/Resume", get_setting("active_user"))
|
|
|
|
|
|
|
|
params = {}
|
|
|
|
params["recursive"] = true
|
|
|
|
params["SortBy"] = "DatePlayed"
|
|
|
|
params["SortOrder"] = "Descending"
|
|
|
|
params["Filters"] = "IsResumable"
|
|
|
|
|
|
|
|
resp = APIRequest(url, params)
|
|
|
|
data = getJson(resp)
|
|
|
|
for each item in data.Items
|
|
|
|
tmp = CreateObject("roSGNode", "HomeData")
|
|
|
|
tmp.json = item
|
|
|
|
results.push(tmp)
|
|
|
|
end for
|
|
|
|
end if
|
|
|
|
m.top.content = results
|
2020-03-12 18:33:45 +00:00
|
|
|
|
|
|
|
end sub
|