mirror of
https://github.com/jellyfin/jellyfin-roku.git
synced 2024-11-24 06:39:47 +00:00
Add seasons to the display
This commit is contained in:
parent
bc510a8a1d
commit
f99db79ae1
@ -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 ]
|
||||
|
53
components/TVSeasonItem.xml
Normal file
53
components/TVSeasonItem.xml
Normal 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>
|
24
components/TVSeasonItemData.xml
Normal file
24
components/TVSeasonItemData.xml
Normal 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>
|
92
components/TVSeasonList.xml
Normal file
92
components/TVSeasonList.xml
Normal 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>
|
@ -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>
|
||||
|
@ -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)
|
||||
|
@ -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" />
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user