2020-05-31 13:46:33 +00:00
|
|
|
function ItemGetPlaybackInfo(id as string, StartTimeTicks = 0 as longinteger)
|
2020-02-15 01:47:06 +00:00
|
|
|
params = {
|
2020-05-31 13:46:33 +00:00
|
|
|
"UserId": get_setting("active_user"),
|
|
|
|
"StartTimeTicks": StartTimeTicks,
|
|
|
|
"IsPlayback": true,
|
|
|
|
"AutoOpenLiveStream": true,
|
|
|
|
"MaxStreamingBitrate": "140000000"
|
2020-02-15 01:47:06 +00:00
|
|
|
}
|
|
|
|
resp = APIRequest(Substitute("Items/{0}/PlaybackInfo", id), params)
|
2020-05-31 13:46:33 +00:00
|
|
|
return getJson(resp)
|
|
|
|
end function
|
|
|
|
|
|
|
|
function ItemPostPlaybackInfo(id as string, StartTimeTicks = 0 as longinteger)
|
|
|
|
body = {
|
|
|
|
"DeviceProfile": getDeviceProfile()
|
|
|
|
}
|
|
|
|
params = {
|
|
|
|
"UserId": get_setting("active_user"),
|
|
|
|
"StartTimeTicks": StartTimeTicks,
|
|
|
|
"IsPlayback": true,
|
|
|
|
"AutoOpenLiveStream": true,
|
|
|
|
"MaxStreamingBitrate": "140000000"
|
|
|
|
}
|
|
|
|
req = APIRequest(Substitute("Items/{0}/PlaybackInfo", id), params)
|
|
|
|
req.SetRequest("POST")
|
|
|
|
return postJson(req, FormatJson(body))
|
2020-02-15 01:47:06 +00:00
|
|
|
end function
|
2019-04-20 22:28:28 +00:00
|
|
|
|
2019-03-19 02:59:23 +00:00
|
|
|
' Search across all libraries
|
2019-10-11 19:01:46 +00:00
|
|
|
function SearchMedia(query as string)
|
2019-05-10 04:42:25 +00:00
|
|
|
' This appears to be done differently on the web now
|
|
|
|
' For each potential type, a separate query is done:
|
|
|
|
' varying item types, and artists, and people
|
|
|
|
resp = APIRequest(Substitute("Users/{0}/Items", get_setting("active_user")), {
|
|
|
|
"searchTerm": query,
|
|
|
|
"IncludePeople": true,
|
|
|
|
"IncludeMedia": true,
|
2020-11-16 21:20:14 +00:00
|
|
|
"IncludeShows": true,
|
2019-05-10 04:42:25 +00:00
|
|
|
"IncludeGenres": false,
|
|
|
|
"IncludeStudios": false,
|
|
|
|
"IncludeArtists": false,
|
2021-06-09 14:11:58 +00:00
|
|
|
"IncludeItemTypes": "TvChannel,Movie,BoxSet,Series,Episode,Trailer,Video,AdultVideo,MusicVideo,Genre,MusicGenre,MusicArtist,Person"
|
2019-10-11 19:01:46 +00:00
|
|
|
"EnableTotalRecordCount": false,
|
2019-05-10 04:42:25 +00:00
|
|
|
"ImageTypeLimit": 1,
|
|
|
|
"Recursive": true
|
|
|
|
})
|
2021-06-09 14:11:58 +00:00
|
|
|
|
2019-03-19 02:59:23 +00:00
|
|
|
data = getJson(resp)
|
2019-04-15 00:16:47 +00:00
|
|
|
results = []
|
2019-05-10 04:42:25 +00:00
|
|
|
for each item in data.Items
|
2019-04-15 00:16:47 +00:00
|
|
|
tmp = CreateObject("roSGNode", "SearchData")
|
2019-05-10 04:42:25 +00:00
|
|
|
tmp.image = PosterImage(item.id)
|
2019-04-15 00:16:47 +00:00
|
|
|
tmp.json = item
|
|
|
|
results.push(tmp)
|
2019-03-19 02:59:23 +00:00
|
|
|
end for
|
2019-04-15 00:16:47 +00:00
|
|
|
data.SearchHints = results
|
2019-03-19 02:59:23 +00:00
|
|
|
return data
|
|
|
|
end function
|
|
|
|
|
|
|
|
' MetaData about an item
|
2019-10-11 19:01:46 +00:00
|
|
|
function ItemMetaData(id as string)
|
2019-03-19 02:59:23 +00:00
|
|
|
url = Substitute("Users/{0}/Items/{1}", get_setting("active_user"), id)
|
|
|
|
resp = APIRequest(url)
|
|
|
|
data = getJson(resp)
|
2021-04-14 07:03:15 +00:00
|
|
|
if data = invalid then return invalid
|
2020-03-08 06:51:40 +00:00
|
|
|
imgParams = {}
|
|
|
|
if data.UserData.PlayedPercentage <> invalid then
|
|
|
|
param = { "PercentPlayed": data.UserData.PlayedPercentage }
|
|
|
|
imgParams.Append(param)
|
|
|
|
end if
|
2019-04-06 00:35:29 +00:00
|
|
|
if data.type = "Movie"
|
|
|
|
tmp = CreateObject("roSGNode", "MovieData")
|
2020-03-08 06:51:40 +00:00
|
|
|
tmp.image = PosterImage(data.id, imgParams)
|
2019-04-15 00:16:47 +00:00
|
|
|
tmp.json = data
|
2019-04-06 00:35:29 +00:00
|
|
|
return tmp
|
|
|
|
else if data.type = "Series"
|
|
|
|
tmp = CreateObject("roSGNode", "SeriesData")
|
2019-05-10 04:24:19 +00:00
|
|
|
tmp.image = PosterImage(data.id)
|
2019-04-15 00:16:47 +00:00
|
|
|
tmp.json = data
|
2019-04-06 00:35:29 +00:00
|
|
|
return tmp
|
2019-04-21 20:11:54 +00:00
|
|
|
else if data.type = "Episode"
|
2020-03-08 06:51:40 +00:00
|
|
|
' param = { "AddPlayedIndicator": data.UserData.Played }
|
|
|
|
' imgParams.Append(param)
|
2019-04-21 20:11:54 +00:00
|
|
|
tmp = CreateObject("roSGNode", "TVEpisodeData")
|
2020-03-08 06:51:40 +00:00
|
|
|
tmp.image = PosterImage(data.id, imgParams)
|
2019-04-21 20:11:54 +00:00
|
|
|
tmp.json = data
|
|
|
|
return tmp
|
2019-04-15 00:24:03 +00:00
|
|
|
else if data.type = "BoxSet"
|
2019-04-15 00:16:47 +00:00
|
|
|
tmp = CreateObject("roSGNode", "CollectionData")
|
2020-03-08 06:51:40 +00:00
|
|
|
tmp.image = PosterImage(data.id, imgParams)
|
2019-04-15 00:16:47 +00:00
|
|
|
tmp.json = item
|
2019-04-21 20:11:54 +00:00
|
|
|
return tmp
|
2020-02-23 04:47:00 +00:00
|
|
|
else if data.type = "Season"
|
|
|
|
tmp = CreateObject("roSGNode", "TVSeasonData")
|
|
|
|
tmp.image = PosterImage(data.id)
|
|
|
|
tmp.json = data
|
|
|
|
return tmp
|
2020-05-13 19:36:38 +00:00
|
|
|
else if data.type = "Video"
|
|
|
|
tmp = CreateObject("roSGNode", "VideoData")
|
|
|
|
tmp.image = PosterImage(data.id)
|
|
|
|
tmp.json = data
|
|
|
|
return tmp
|
2020-05-31 13:46:33 +00:00
|
|
|
else if data.type = "TvChannel"
|
|
|
|
tmp = CreateObject("roSGNode", "ChannelData")
|
|
|
|
tmp.image = PosterImage(data.id)
|
|
|
|
tmp.json = data
|
|
|
|
return tmp
|
2019-04-06 00:35:29 +00:00
|
|
|
else
|
2020-02-23 04:47:00 +00:00
|
|
|
print "Items.brs::ItemMetaData processed unhandled type: " data.type
|
2019-04-06 00:35:29 +00:00
|
|
|
' Return json if we don't know what it is
|
|
|
|
return data
|
|
|
|
end if
|
2019-03-19 02:59:23 +00:00
|
|
|
return data
|
|
|
|
end function
|
|
|
|
|
|
|
|
' Seasons for a TV Show
|
2019-10-11 19:01:46 +00:00
|
|
|
function TVSeasons(id as string)
|
2019-03-19 02:59:23 +00:00
|
|
|
url = Substitute("Shows/{0}/Seasons", id)
|
2019-10-11 19:01:46 +00:00
|
|
|
resp = APIRequest(url, { "UserId": get_setting("active_user") })
|
2019-03-19 02:59:23 +00:00
|
|
|
|
|
|
|
data = getJson(resp)
|
2019-04-15 00:16:47 +00:00
|
|
|
results = []
|
2019-03-19 02:59:23 +00:00
|
|
|
for each item in data.Items
|
2020-02-22 16:28:35 +00:00
|
|
|
imgParams = { "AddPlayedIndicator": item.UserData.Played }
|
|
|
|
if item.UserData.UnplayedItemCount > 0 then
|
|
|
|
param = { "UnplayedCount" : item.UserData.UnplayedItemCount }
|
|
|
|
imgParams.Append(param)
|
|
|
|
end if
|
2019-04-15 00:16:47 +00:00
|
|
|
tmp = CreateObject("roSGNode", "TVEpisodeData")
|
2020-02-22 16:28:35 +00:00
|
|
|
tmp.image = PosterImage(item.id, imgParams)
|
2019-04-15 00:16:47 +00:00
|
|
|
tmp.json = item
|
|
|
|
results.push(tmp)
|
2019-03-19 02:59:23 +00:00
|
|
|
end for
|
2019-04-15 00:16:47 +00:00
|
|
|
data.Items = results
|
2019-03-19 02:59:23 +00:00
|
|
|
return data
|
|
|
|
end function
|
|
|
|
|
2019-10-11 19:01:46 +00:00
|
|
|
function TVEpisodes(show_id as string, season_id as string)
|
2019-04-14 04:47:27 +00:00
|
|
|
url = Substitute("Shows/{0}/Episodes", show_id)
|
2019-10-11 19:01:46 +00:00
|
|
|
resp = APIRequest(url, { "seasonId": season_id, "UserId": get_setting("active_user") })
|
2019-04-14 04:47:27 +00:00
|
|
|
|
|
|
|
data = getJson(resp)
|
2019-04-15 00:16:47 +00:00
|
|
|
results = []
|
2019-04-14 04:47:27 +00:00
|
|
|
for each item in data.Items
|
2020-02-23 04:47:00 +00:00
|
|
|
imgParams = { "AddPlayedIndicator": item.UserData.Played, "maxWidth": 712, "maxheight": 400 }
|
2020-03-08 06:51:40 +00:00
|
|
|
if item.UserData.PlayedPercentage <> invalid then
|
|
|
|
param = { "PercentPlayed": item.UserData.PlayedPercentage }
|
|
|
|
imgParams.Append(param)
|
|
|
|
end if
|
2019-04-15 00:16:47 +00:00
|
|
|
tmp = CreateObject("roSGNode", "TVEpisodeData")
|
2020-02-22 16:28:35 +00:00
|
|
|
tmp.image = PosterImage(item.id, imgParams)
|
2019-12-07 02:49:37 +00:00
|
|
|
if tmp.image <> invalid
|
|
|
|
tmp.image.posterDisplayMode = "scaleToFit"
|
|
|
|
end if
|
2019-04-15 00:16:47 +00:00
|
|
|
tmp.json = item
|
2020-02-23 04:47:00 +00:00
|
|
|
tmp.overview = ItemMetaData(item.id).overview
|
2019-04-15 00:16:47 +00:00
|
|
|
results.push(tmp)
|
2019-04-14 04:47:27 +00:00
|
|
|
end for
|
2019-04-15 00:16:47 +00:00
|
|
|
data.Items = results
|
2019-04-14 04:47:27 +00:00
|
|
|
return data
|
|
|
|
end function
|