Add seasons to the display

This commit is contained in:
Nick Bisby 2019-03-10 21:35:48 -05:00
parent bc510a8a1d
commit f99db79ae1
No known key found for this signature in database
GPG Key ID: F6E0C4E6D0B5EB36
8 changed files with 200 additions and 1 deletions

View File

@ -39,7 +39,7 @@
' size of the whole row
m.top.itemSize = [dimensions["width"] - border*2, itemHeight]
' spacing between rows
m.top.itemSpacing = [ 0, 10 ]
m.top.itemSpacing = [ 0, 30 ]
' size of the item in the row
m.top.rowItemSize = [ itemWidth, itemHeight ]

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="TVSeasonItem" extends="Group">
<children>
<Poster id="poster"
translation="[2, 0]"
/>
<Label id="title"
horizAlign="center"
font="font:SmallSystemFont"
/>
</children>
<interface>
<field id="itemContent" type="node" onChange="itemContentChanged"/>
</interface>
<script type="text/brightscript">
<![CDATA[
sub init()
m.title = m.top.findNode("title")
m.poster = m.top.findNode("poster")
updateSize()
end sub
sub updateSize()
m.title = m.top.findNode("title")
m.poster = m.top.findNode("poster")
maxSize = m.top.getParent().itemSize
m.poster.width = int(maxSize[0]) - 4
m.poster.height = m.poster.width * 1.5
m.title.width = m.poster.width
m.title.height = int(maxSize[1]) - m.poster.height
m.title.translation = [0, m.poster.height]
end sub
function itemContentChanged() as void
updateSize()
' re-declare this because init doesnt re-run
' when we come back from elsewhere
m.title = m.top.findNode("title")
m.poster = m.top.findNode("poster")
itemData = m.top.itemContent
m.title.text = itemData.title
m.poster.uri = itemData.posterUrl
end function
]]>
</script>
</component>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="TVSeasonItemData" extends="ContentNode">
<interface>
<field id="title" type="string" />
<field id="posterUrl" type="string" />
<field id="showID" type="string" />
<field id="description" type="string" />
<field id="full_data" type="associativearray" onChange="setFields" />
<function name="getPoster" />
</interface>
<script type="text/brightscript" uri="pkg:/source/config.brs" />
<script type="text/brightscript" uri="pkg:/source/JellyfinAPI.brs" />
<script type="text/brightscript">
<![CDATA[
sub setFields()
datum = m.top.full_data
m.top.title = datum.name
m.top.showID = datum.id
m.top.posterURL = ImageURL(datum.id)
m.top.description = datum.overview
end sub
]]>
</script>
</component>

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="TVSeasonRow" extends="RowList">
<interface>
<field id="rowSize" type="int" />
<field id="TVSeasonData" type="associativearray" onChange="setData" />
</interface>
<script type="text/brightscript">
<![CDATA[
' TODO - make this not a "row" list
sub init()
m.top.itemComponentName = "TVSeasonItem"
m.top.content = getData()
'm.top.rowFocusAnimationStyle = "floatingFocus"
'm.top.vertFocusAnimationStyle = "floatingFocus"
m.top.showRowLabel = [false]
updateSize()
m.top.setfocus(true)
end sub
sub updateSize()
m.top.numrows = 1
m.top.rowSize = 5
dimensions = m.top.getScene().currentDesignResolution
border = 75
m.top.translation = [border, border]
textHeight = 50
' Do we decide width by rowSize, or rowSize by width...
itemWidth = (dimensions["width"] - border*2) / m.top.rowSize
itemHeight = itemWidth * 1.5 + textHeight
m.top.visible = true
' size of the whole row
m.top.itemSize = [dimensions["width"] - border*2, itemHeight]
' spacing between rows
m.top.itemSpacing = [ 0, 10 ]
' size of the item in the row
m.top.rowItemSize = [ itemWidth, itemHeight ]
' spacing between items in a row
m.top.rowItemSpacing = [ 0, 0 ]
end sub
function setData()
seasonData = m.top.TVSeasonData
rowsize = m.top.rowSize
n = seasonData.items.count()
' Test for no remainder
if int(n/rowsize) = n/rowsize then
m.top.numRows = n/rowsize
else
m.top.numRows = n/rowsize + 1
end if
m.top.content = getData()
end function
function getData()
if m.top.TVSeasonData = invalid then
data = CreateObject("roSGNode", "ContentNode")
return data
end if
seasonData = m.top.TVSeasonData
rowsize = m.top.rowSize
data = CreateObject("roSGNode", "ContentNode")
for rownum=1 to m.top.numRows
row = data.CreateChild("ContentNode")
for i=1 to rowsize
index = (rownum - 1) * rowsize + i
if index > seasonData.items.count() then
exit for
end if
datum = seasonData.Items[index-1]
item = row.CreateChild("TVSeasonItemData")
item.full_data = datum
end for
end for
return data
end function
]]>
</script>
</component>

View File

@ -5,6 +5,8 @@
<field id="posterUrl" type="string" />
<field id="showID" type="string" />
<field id="description" type="string" />
<field id="seasons" type="associativearray" />
<field id="nextup" type="associativearray" />
<field id="full_data" type="associativearray" onChange="setFields" />
<function name="getPoster" />
</interface>
@ -18,6 +20,8 @@
m.top.showID = datum.id
m.top.posterURL = ImageURL(datum.id)
m.top.description = datum.overview
m.top.seasons = TVSeasons(datum.id)
m.top.nextup = TVNext(datum.id)
end sub
]]>
</script>

View File

@ -27,6 +27,17 @@ sub itemContentChanged()
if itemData.taglines.count() > 0
setFieldText("tagline", itemData.taglines[0])
end if
setSeasons()
end sub
sub setSeasons()
itemData = m.top.itemContent
row = m.top.findNode("TVSeasonSelect")
print itemData.seasons
row.TVSeasonData = itemData.seasons
end sub
sub setFieldText(field as string, value)

View File

@ -25,6 +25,8 @@
</LayoutGroup>
</LayoutGroup>
<!-- Next Up -->
<TVSeasonRow id="TVSeasonSelect" visible="true" translation="[150, 800]" />
</children>
<interface>
<field id="itemContent" type="node" onChange="itemContentChanged" />

View File

@ -180,3 +180,16 @@ function ItemMetaData(id as String)
resp = APIRequest(url)
return parseRequest(resp)
end function
function TVSeasons(id as String)
url = Substitute("Shows/{0}/Seasons", id)
resp = APIRequest(url, {"UserId": get_setting("active_user")})
return parseRequest(resp)
end function
function TVNext(id as String)
url = Substitute("Shows/NextUp", id)
resp = APIRequest(url, {"UserId": get_setting("active_user"), "SeriesId": id})
return parseRequest(resp)
end function