2020-06-10 16:43:32 +00:00
|
|
|
sub init()
|
|
|
|
m.top.functionName = "loadItems"
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub loadItems()
|
|
|
|
|
|
|
|
results = []
|
|
|
|
|
2020-08-16 14:44:03 +00:00
|
|
|
sort_field = m.top.sortField
|
2020-10-17 19:07:32 +00:00
|
|
|
|
2020-08-16 14:44:03 +00:00
|
|
|
if m.top.sortAscending = true then
|
|
|
|
sort_order = "Ascending"
|
|
|
|
else
|
|
|
|
sort_order = "Descending"
|
|
|
|
end if
|
2020-06-10 16:43:32 +00:00
|
|
|
|
2020-10-24 22:50:07 +00:00
|
|
|
|
2020-06-10 16:43:32 +00:00
|
|
|
params = {
|
|
|
|
limit: m.top.limit,
|
|
|
|
StartIndex: m.top.startIndex,
|
|
|
|
parentid: m.top.itemId,
|
|
|
|
SortBy: sort_field,
|
|
|
|
SortOrder: sort_order,
|
2020-10-30 17:23:28 +00:00
|
|
|
recursive: m.top.recursive,
|
2020-08-08 20:43:37 +00:00
|
|
|
Fields: "Overview"
|
2020-06-10 16:43:32 +00:00
|
|
|
}
|
|
|
|
|
2020-10-24 22:50:07 +00:00
|
|
|
filter = m.top.filter
|
|
|
|
if filter = "All" or filter = "all" then
|
|
|
|
' do nothing
|
|
|
|
else if filter = "Favorites" then
|
|
|
|
params.append({ Filters: "IsFavorite"})
|
|
|
|
end if
|
|
|
|
|
2020-06-10 16:43:32 +00:00
|
|
|
if m.top.ItemType <> "" then
|
|
|
|
params.append({ IncludeItemTypes: m.top.ItemType})
|
|
|
|
end if
|
|
|
|
|
2020-10-17 19:07:32 +00:00
|
|
|
if m.top.ItemType = "LiveTV" then
|
|
|
|
url = "LiveTv/Channels"
|
|
|
|
else
|
|
|
|
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
|
|
|
|
end if
|
2020-06-10 16:43:32 +00:00
|
|
|
resp = APIRequest(url, params)
|
|
|
|
data = getJson(resp)
|
|
|
|
|
|
|
|
if data.TotalRecordCount <> invalid then
|
|
|
|
m.top.totalRecordCount = data.TotalRecordCount
|
|
|
|
end if
|
2020-10-17 19:07:32 +00:00
|
|
|
|
2020-06-10 16:43:32 +00:00
|
|
|
for each item in data.Items
|
|
|
|
|
|
|
|
tmp = invalid
|
|
|
|
if item.Type = "Movie" then
|
|
|
|
tmp = CreateObject("roSGNode", "MovieData")
|
2020-06-15 16:05:48 +00:00
|
|
|
else if item.Type = "Series" then
|
|
|
|
tmp = CreateObject("roSGNode", "SeriesData")
|
2020-06-23 16:12:47 +00:00
|
|
|
else if item.Type = "BoxSet" then
|
|
|
|
tmp = CreateObject("roSGNode", "CollectionData")
|
2020-10-17 19:07:32 +00:00
|
|
|
else if item.Type = "TvChannel" then
|
|
|
|
tmp = CreateObject("roSGNode", "ChannelData")
|
2021-04-10 10:20:02 +00:00
|
|
|
else if item.Type = "Folder" or item.Type = "ChannelFolderItem" then
|
2020-10-30 17:23:28 +00:00
|
|
|
tmp = CreateObject("roSGNode", "FolderData")
|
2020-10-27 17:12:18 +00:00
|
|
|
else if item.Type = "Video" then
|
|
|
|
tmp = CreateObject("roSGNode", "VideoData")
|
2020-06-10 16:43:32 +00:00
|
|
|
else
|
|
|
|
print "Unknown Type: " item.Type
|
|
|
|
end if
|
2020-10-17 19:07:32 +00:00
|
|
|
|
2020-06-10 16:43:32 +00:00
|
|
|
if tmp <> invalid then
|
|
|
|
|
|
|
|
tmp.json = item
|
|
|
|
results.push(tmp)
|
|
|
|
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
|
|
|
|
m.top.content = results
|
|
|
|
|
|
|
|
end sub
|