Merge pull request #1247 from cewert/reintroduce-api-sdk

This commit is contained in:
Charles Ewert 2023-05-19 22:14:49 -04:00 committed by GitHub
commit 5dbbc98c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 2227 additions and 35 deletions

View File

@ -1,12 +1,12 @@
import "pkg:/source/utils/config.brs"
import "pkg:/source/roku_modules/api/api.brs"
import "pkg:/source/api/sdk.bs"
sub init()
m.top.functionName = "getNextEpisodeTask"
end sub
sub getNextEpisodeTask()
m.nextEpisodeData = api_API().shows.getepisodes(m.top.showID, {
m.nextEpisodeData = api.shows.GetEpisodes(m.top.showID, {
UserId: get_setting("active_user"),
StartItemId: m.top.videoID,
Limit: 2

View File

@ -2,7 +2,7 @@ import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/misc.brs"
import "pkg:/source/utils/deviceCapabilities.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/roku_modules/api/api.brs"
import "pkg:/source/api/sdk.bs"
sub init()
m.top.functionName = "getPlaybackInfoTask"
@ -35,7 +35,7 @@ end function
' Returns an array of playback info to be displayed during playback.
' In the future, with a custom playback info view, we can return an associated array.
sub getPlaybackInfoTask()
sessions = api_API().sessions.get()
sessions = api.sessions.Get()
m.playbackInfo = ItemPostPlaybackInfo(m.top.videoID)

View File

@ -1,12 +1,12 @@
import "pkg:/source/utils/config.brs"
import "pkg:/source/roku_modules/api/api.brs"
import "pkg:/source/api/sdk.bs"
sub init()
m.top.functionName = "getShuffleEpisodesTask"
end sub
sub getShuffleEpisodesTask()
data = api_API().shows.getepisodes(m.top.showID, {
data = api.shows.GetEpisodes(m.top.showID, {
UserId: get_setting("active_user"),
SortBy: "Random",
Limit: 200

View File

@ -1,11 +1,11 @@
import "pkg:/source/api/Items.brs"
import "pkg:/source/roku_modules/api/api.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/misc.brs"
import "pkg:/source/api/Image.brs"
import "pkg:/source/utils/deviceCapabilities.brs"
import "pkg:/source/roku_modules/log/LogMixin.brs"
import "pkg:/source/api/sdk.bs"
sub init()
m.log = log.Logger("LoadItemsTask2")
@ -31,9 +31,9 @@ sub loadItems()
end if
if m.top.ItemType = "LogoImage"
logoImageExists = api_API().items.headimageurlbyname(m.top.itemId, "logo")
logoImageExists = api.items.HeadImageURLByName(m.top.itemId, "logo")
if logoImageExists
m.top.content = [api_API().items.getimageurl(m.top.itemId, "logo", 0, { "maxHeight": 500, "maxWidth": 500, "quality": "90" })]
m.top.content = [api.items.GetImageURL(m.top.itemId, "logo", 0, { "maxHeight": 500, "maxWidth": 500, "quality": "90" })]
else
m.top.content = []
end if
@ -168,7 +168,7 @@ sub loadItems()
tmp = CreateObject("roSGNode", "ContentNode")
tmp.title = item.name
genreData = api_API().users.getitemsbyquery(get_setting("active_user"), {
genreData = api.users.GetItemsByQuery(get_setting("active_user"), {
SortBy: "Random",
SortOrder: "Ascending",
IncludeItemTypes: m.top.itemType,
@ -192,7 +192,7 @@ sub loadItems()
row.type = "Folder"
if LCase(m.top.itemType) = "movie"
genreItemImage = api_API().items.getimageurl(item.id)
genreItemImage = api.items.GetImageURL(item.id)
else
genreItemImage = invalid
row.posterURL = invalid
@ -210,7 +210,7 @@ sub loadItems()
row = tmp.createChild("SeriesData")
end if
genreItemImage = api_API().items.getimageurl(genreItem.id)
genreItemImage = api.items.GetImageURL(genreItem.id)
row.title = genreItem.name
row.FHDPOSTERURL = genreItemImage
row.HDPOSTERURL = genreItemImage
@ -225,7 +225,7 @@ sub loadItems()
else if item.Type = "MusicAlbum"
tmp = CreateObject("roSGNode", "MusicAlbumData")
tmp.type = "MusicAlbum"
if api_API().items.headimageurlbyname(item.id, "primary")
if api.items.HeadImageURLByName(item.id, "primary")
tmp.posterURL = ImageURL(item.id, "Primary")
else
tmp.posterURL = ImageURL(item.id, "backdrop")
@ -235,14 +235,14 @@ sub loadItems()
else if item.Type = "Audio"
tmp = CreateObject("roSGNode", "MusicSongData")
tmp.type = "Audio"
tmp.image = api_API().items.getimageurl(item.id, "primary", 0, { "maxHeight": 280, "maxWidth": 280, "quality": "90" })
tmp.image = api.items.GetImageURL(item.id, "primary", 0, { "maxHeight": 280, "maxWidth": 280, "quality": "90" })
else if item.Type = "MusicGenre"
tmp = CreateObject("roSGNode", "FolderData")
tmp.title = item.name
tmp.parentFolder = m.top.itemId
tmp.json = item
tmp.type = "Folder"
tmp.posterUrl = api_API().items.getimageurl(item.id, "primary", 0, { "maxHeight": 280, "maxWidth": 280, "quality": "90" })
tmp.posterUrl = api.items.GetImageURL(item.id, "primary", 0, { "maxHeight": 280, "maxWidth": 280, "quality": "90" })
else
m.log.warn("Unknown Type", item.Type)

View File

@ -1,7 +1,6 @@
import "pkg:/source/utils/misc.brs"
import "pkg:/source/api/Items.brs"
import "pkg:/source/api/UserLibrary.brs"
import "pkg:/source/roku_modules/api/api.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/api/Image.brs"

View File

@ -3,7 +3,6 @@ import "pkg:/source/utils/config.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/api/Image.brs"
import "pkg:/source/utils/deviceCapabilities.brs"
import "pkg:/source/roku_modules/api/api.brs"
sub setupNodes()
m.options = m.top.findNode("options")

View File

@ -1,6 +1,5 @@
import "pkg:/source/utils/misc.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/roku_modules/api/api.brs"
sub init()
m.playbackTimer = m.top.findNode("playbackTimer")

View File

@ -1,11 +1,11 @@
import "pkg:/source/utils/config.brs"
import "pkg:/source/roku_modules/api/api.brs"
import "pkg:/source/api/sdk.bs"
sub init()
m.top.functionName = "getFiltersTask"
end sub
sub getFiltersTask()
m.filters = api_API().items.getFilters(m.top.params)
m.filters = api.items.GetFilters(m.top.params)
m.top.filters = m.filters
end sub

View File

@ -4,7 +4,7 @@ import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/misc.brs"
import "pkg:/source/utils/deviceCapabilities.brs"
import "pkg:/source/api/Image.brs"
import "pkg:/source/roku_modules/api/api.brs"
import "pkg:/source/api/sdk.bs"
sub init()
m.top.functionName = "loadItems"
@ -206,7 +206,7 @@ sub loadItems()
end for
end if
else if m.top.itemsToLoad = "additionalparts"
additionalParts = api_API().videos.getAdditionalParts(m.top.itemId)
additionalParts = api.videos.GetAdditionalParts(m.top.itemId)
if isValid(additionalParts)
for each part in additionalParts.items
tmp = CreateObject("roSGNode", "ExtrasData")

View File

@ -1,6 +1,5 @@
import "pkg:/source/utils/misc.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/roku_modules/api/api.brs"
sub init()
' Hide the overhang on init to prevent showing 2 clocks

7
package-lock.json generated
View File

@ -10,7 +10,6 @@
"hasInstallScript": true,
"license": "GPL-2.0",
"dependencies": {
"api": "npm:jellyfin-api-bs-client@1.0.6",
"bgv": "npm:button-group-vert@1.0.2",
"brighterscript-formatter": "1.6.28",
"intKeyboard": "npm:integer-keyboard@1.0.12",
@ -368,12 +367,6 @@
"node": ">= 8"
}
},
"node_modules/api": {
"name": "jellyfin-api-bs-client",
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/jellyfin-api-bs-client/-/jellyfin-api-bs-client-1.0.6.tgz",
"integrity": "sha512-lZXRUvH0Tz3itGgI2o4EArCaoaYCJf8fM+NrYzGnJlxBSnon6RAWt1XxookfyeSVXghQtZUHY+IXjM/byUnoFw=="
},
"node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",

View File

@ -3,7 +3,6 @@
"version": "1.6.6",
"description": "Roku app for Jellyfin media server",
"dependencies": {
"api": "npm:jellyfin-api-bs-client@1.0.6",
"bgv": "npm:button-group-vert@1.0.2",
"brighterscript-formatter": "1.6.28",
"intKeyboard": "npm:integer-keyboard@1.0.12",

View File

@ -43,7 +43,7 @@ sub Main (args as dynamic) as void
m.scene.observeField("exit", m.port)
' Downloads and stores a fallback font to tmp:/
configEncoding = api_API().system.getconfigurationbyname("encoding")
configEncoding = api.system.GetConfigurationByName("encoding")
if isValid(configEncoding) and isValid(configEncoding.EnableFallbackFont)
if configEncoding.EnableFallbackFont
@ -460,7 +460,7 @@ sub Main (args as dynamic) as void
dialog.title = tr("Loading trailer")
m.scene.dialog = dialog
trailerData = api_API().users.getlocaltrailers(get_setting("active_user"), group.id)
trailerData = api.users.GetLocalTrailers(get_setting("active_user"), group.id)
if isValid(trailerData) and isValid(trailerData[0]) and isValid(trailerData[0].id)
m.global.queueManager.callFunc("clear")

View File

@ -497,7 +497,7 @@ function CreateMovieDetailsGroup(movie as object) as dynamic
m.global.sceneManager.callFunc("pushScene", group)
group.itemContent = movieMetaData
' local trailers
trailerData = api_API().users.getlocaltrailers(get_setting("active_user"), movie.id)
trailerData = api.users.GetLocalTrailers(get_setting("active_user"), movie.id)
if isValid(trailerData)
group.trailerAvailable = trailerData.Count() > 0
end if

View File

@ -472,7 +472,7 @@ end sub
' Returns an array of playback info to be displayed during playback.
' In the future, with a custom playback info view, we can return an associated array.
function GetPlaybackInfo()
sessions = api_API().sessions.get()
sessions = api.sessions.Get()
if isValid(sessions) and sessions.Count() > 0
return GetTranscodingStats(sessions[0])
end if

View File

@ -95,6 +95,39 @@ function postVoid(req, data = "" as string) as boolean
return false
end function
function headVoid(req) as boolean
req.setMessagePort(CreateObject("roMessagePort"))
req.AddHeader("Content-Type", "application/json")
req.AsyncHead()
resp = wait(30000, req.GetMessagePort())
if type(resp) <> "roUrlEvent"
return false
end if
if resp.GetResponseCode() = 200
return true
end if
return false
end function
function getVoid(req) as boolean
req.setMessagePort(CreateObject("roMessagePort"))
req.AddHeader("Content-Type", "application/json")
req.AsyncGetToString()
resp = wait(30000, req.GetMessagePort())
if type(resp) <> "roUrlEvent"
return false
end if
if resp.GetResponseCode() = 200
return true
end if
return false
end function
function postJson(req, data = "" as string)
req.setMessagePort(CreateObject("roMessagePort"))
req.AddHeader("Content-Type", "application/json")
@ -137,6 +170,23 @@ function get_url()
return serverURL
end function
function getString(req)
data = req.GetToString()
return data
end function
function postString(req, data = "" as string)
req.setMessagePort(CreateObject("roMessagePort"))
req.AddHeader("Content-Type", "application/json")
req.AsyncPostFromString(data)
resp = wait(30000, req.GetMessagePort())
if type(resp) <> "roUrlEvent"
return invalid
end if
return resp.getString()
end function
function authorize_request(request)
user = get_setting("active_user")

2154
source/api/sdk.bs Normal file

File diff suppressed because it is too large Load Diff