Make things use Content rather than json

This commit is contained in:
Nick Bisby 2019-04-14 19:16:47 -05:00
parent 3c3960551e
commit 5fd5c9eec2
No known key found for this signature in database
GPG Key ID: F6E0C4E6D0B5EB36
16 changed files with 132 additions and 87 deletions

View File

@ -1,5 +1,6 @@
sub itemContentChanged()
itemData = m.top.itemContent.full_data
item = m.top.itemContent
itemData = item.json
m.top.findNode("poster").uri = m.top.itemContent.posterURL
@ -44,7 +45,7 @@ sub setFieldText(field as string, value)
end sub
function getRuntime() as Integer
itemData = m.top.itemContent.full_data
itemData = m.top.itemContent.json
' A tick is .1ms, so 1/10,000,000 for ticks to seconds,
' then 1/60 for seconds to minutess... 1/600,000,000
@ -52,7 +53,7 @@ function getRuntime() as Integer
end function
function getEndTime() as string
itemData = m.top.itemContent.full_data
itemData = m.top.itemContent.json
date = CreateObject("roDateTime")
duration_s = int(itemData.RunTimeTicks / 10000000.0)

View File

@ -80,9 +80,8 @@
if index > itemData.items.count() then
exit for
end if
datum = itemData.Items[index-1]
item = row.CreateChild("CollectionData")
item.full_data = datum
item = itemData.Items[index-1]
row.appendChild(item)
end for
end for
return data

View File

@ -1,29 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="CollectionData" extends="ContentNode">
<interface>
<field id="id" type="string" />
<field id="title" type="string" />
<field id="posterUrl" type="string" />
<field id="collectionID" type="string" />
<field id="description" type="string" />
<field id="favorite" type="boolean" />
<field id="watched" type="boolean" />
<field id="full_data" type="associativearray" onChange="setFields" />
<field id="json" type="associativearray" onChange="setFields" />
</interface>
<script type="text/brightscript">
<![CDATA[
sub setFields()
datum = m.top.full_data
datum = m.top.json
m.top.id = datum.id
m.top.title = datum.name
m.top.collectionID = datum.id
m.top.overview = datum.overview
m.top.favorite = datum.UserData.isFavorite
m.top.watched = datum.UserData.played
if datum.posterURL <> invalid
m.top.posterURL = datum.posterURL
else
m.top.posterURL = ""
end if
m.top.description = datum.overview
m.top.favorite = datum.UserData.isFavorite
m.top.watched = datum.UserData.played
end sub
]]>
</script>

View File

@ -8,22 +8,24 @@
<field id="favorite" type="boolean" />
<field id="watched" type="boolean" />
<field id="seasons" type="associativearray" />
<field id="full_data" type="associativearray" onChange="setFields" />
<field id="json" type="associativearray" onChange="setFields" />
</interface>
<script type="text/brightscript">
<![CDATA[
sub setFields()
datum = m.top.full_data
datum = m.top.json
m.top.id = datum.id
m.top.title = datum.name
m.top.movieID = datum.id
m.top.overview = datum.overview
m.top.favorite = datum.UserData.isFavorite
m.top.watched = datum.UserData.played
if datum.posterURL <> invalid
m.top.posterURL = datum.posterURL
else
m.top.posterURL = ""
end if
m.top.description = datum.overview
m.top.favorite = datum.UserData.isFavorite
m.top.watched = datum.UserData.played
end sub
]]>
</script>

View File

@ -1,19 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="SearchData" extends="ContentNode">
<interface>
<field id="id" type="string" />
<field id="type" type="string" />
<field id="title" type="string" />
<field id="posterUrl" type="string" />
<field id="mediaType" type="string" />
<field id="mediaID" type="string" />
<field id="full_data" type="associativearray" onChange="setFields" />
<field id="json" type="associativearray" onChange="setFields" />
</interface>
<script type="text/brightscript">
<![CDATA[
sub setFields()
datum = m.top.full_data
datum = m.top.json
m.top.id = datum.id
m.top.title = datum.name
m.top.mediaID = datum.id
m.top.mediaType = datum.Type
m.top.type = datum.Type
if datum.posterURL <> invalid
m.top.posterURL = datum.posterURL
else

View File

@ -1,27 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="SeriesData" extends="ContentNode">
<interface>
<field id="id" type="string" />
<field id="title" type="string" />
<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" />
<field id="posterURL" type="string" />
<field id="json" type="associativearray" onChange="setFields" />
<function name="loadSeasons" />
</interface>
<script type="text/brightscript">
<![CDATA[
sub setFields()
datum = m.top.full_data
datum = m.top.json
m.top.id = datum.id
m.top.title = datum.name
m.top.showID = datum.id
m.top.overview = datum.overview
if datum.posterURL <> invalid
m.top.posterURL = datum.posterURL
else
m.top.posterURL = ""
end if
m.top.description = datum.overview
'm.top.seasons = TVSeasons(datum.id)
'm.top.nextup = TVNext(datum.id)
end sub

View File

@ -1,25 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="TVEpisodeData" extends="ContentNode">
<interface>
<field id="id" type="string" />
<field id="title" type="string" />
<field id="posterUrl" type="string" />
<field id="posterURL" type="string" />
<field id="showID" type="string" />
<field id="seasonID" type="string" />
<field id="description" type="string" />
<field id="full_data" type="associativearray" onChange="setFields" />
<field id="json" type="associativearray" onChange="setFields" />
<function name="loadSeasons" />
</interface>
<script type="text/brightscript">
<![CDATA[
sub setFields()
datum = m.top.full_data
datum = m.top.json
m.top.id = datum.id
m.top.title = datum.name
m.top.showID = datum.SeriesID
m.top.seasonID = datum.SeasonID
m.top.overview = datum.overview
if datum.posterURL <> invalid
m.top.posterURL = datum.posterURL
else
m.top.posterURL = ""
end if
m.top.description = datum.overview
end sub
]]>
</script>

View File

@ -1,25 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="TVSeasonData" extends="ContentNode">
<interface>
<field id="id" type="string" />
<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" />
<field id="json" type="associativearray" onChange="setFields" />
<function name="getPoster" />
</interface>
<script type="text/brightscript">
<![CDATA[
sub setFields()
datum = m.top.full_data
datum = m.top.json
m.top.id = datum.id
m.top.title = datum.name
m.top.showID = datum.id
m.top.overview = datum.overview
if datum.posterURL <> invalid
m.top.posterURL = datum.posterURL
else
m.top.posterURL = ""
end if
m.top.description = datum.overview
end sub
]]>
</script>

View File

@ -1,5 +1,6 @@
sub itemContentChanged()
itemData = m.top.itemContent.full_data
item = m.top.itemContent
itemData = item.json
m.top.findNode("moviePoster").uri = m.top.itemContent.posterURL
@ -44,7 +45,7 @@ sub setFieldText(field as string, value)
end sub
function getRuntime() as Integer
itemData = m.top.itemContent.full_data
itemData = m.top.itemContent.json
' A tick is .1ms, so 1/10,000,000 for ticks to seconds,
' then 1/60 for seconds to minutess... 1/600,000,000
@ -52,7 +53,7 @@ function getRuntime() as Integer
end function
function getEndTime() as string
itemData = m.top.itemContent.full_data
itemData = m.top.itemContent.json
date = CreateObject("roDateTime")
duration_s = int(itemData.RunTimeTicks / 10000000.0)

View File

@ -67,8 +67,8 @@
}
for each item in itemData.searchHints
if content_types[item.Type] <> invalid
content_types[item.Type].count += 1
if content_types[item.type] <> invalid
content_types[item.type].count += 1
end if
end for
@ -89,8 +89,7 @@
row.title = title
for each item in itemData.SearchHints
if item.type = type_filter
child = row.createChild("SearchData")
child.full_data = item
row.appendChild(item)
end if
end for
end function

View File

@ -1,5 +1,7 @@
sub itemContentChanged()
itemData = m.top.itemContent.full_data
' TODO - make things use item rather than itemData
item = m.top.itemContent
itemData = item.json
m.top.findNode("tvshowPoster").uri = m.top.itemContent.posterURL
@ -38,7 +40,7 @@ sub setFieldText(field as string, value)
end sub
function getRuntime() as Integer
itemData = m.top.itemContent.full_data
itemData = m.top.itemContent.json
' A tick is .1ms, so 1/10,000,000 for ticks to seconds,
' then 1/60 for seconds to minutess... 1/600,000,000
@ -46,7 +48,7 @@ function getRuntime() as Integer
end function
function getEndTime() as string
itemData = m.top.itemContent.full_data
itemData = m.top.itemContent.json
date = CreateObject("roDateTime")
duration_s = int(itemData.RunTimeTicks / 10000000.0)
@ -69,7 +71,7 @@ function getEndTime() as string
end function
function getHistory() as string
itemData = m.top.itemContent.full_data
itemData = m.top.itemContent.json
' Aired Fridays at 9:30 PM on ABC (US)
airwords = invalid

View File

@ -66,9 +66,8 @@
rowsize = m.top.rowSize
data = CreateObject("roSGNode", "ContentNode")
row = data.CreateChild("ContentNode")
for each datum in episodeData.items
item = row.CreateChild("TVEpisodeData")
item.full_data = datum
for each item in episodeData.items
row.appendChild(item)
end for
m.top.content = data
return data

View File

@ -60,9 +60,8 @@
data = CreateObject("roSGNode", "ContentNode")
row = data.CreateChild("ContentNode")
row.title = "Seasons"
for each datum in seasonData.items
item = row.CreateChild("TVSeasonData")
item.full_data = datum
for each item in seasonData.items
row.appendChild(item)
end for
m.top.content = data
return data

View File

@ -102,6 +102,8 @@ sub ShowLibrarySelect()
scene.libraries = libs
scene.observeField("librarySelected", port)
library = scene.findNode("LibrarySelect")
search = scene.findNode("search")
search.observeField("escape", port)
search.observeField("search_value", port)
@ -252,7 +254,7 @@ sub ShowMovieOptions(library)
options.setFocus(true)
else if nodeEventQ(msg, "itemSelected")
target = getMsgRowTarget(msg)
ShowMovieDetails(target.movieID)
ShowMovieDetails(target)
else
print msg
print msg.getField()
@ -261,7 +263,7 @@ sub ShowMovieOptions(library)
end while
end sub
sub ShowMovieDetails(movie_id)
sub ShowMovieDetails(movie)
port = CreateObject("roMessagePort")
screen = CreateObject("roSGScreen")
screen.setMessagePort(port)
@ -271,7 +273,8 @@ sub ShowMovieDetails(movie_id)
themeScene(scene)
scene.itemContent = ItemMetaData(movie_id)
movie = ItemMetaData(movie.id)
scene.itemContent = movie
buttons = scene.findNode("buttons")
for each b in buttons.getChildren(-1, 0)
@ -284,21 +287,21 @@ sub ShowMovieDetails(movie_id)
return
else if nodeEventQ(msg, "buttonSelected")
if msg.getNode() = "play-button"
showVideoPlayer(movie_id)
showVideoPlayer(movie.id)
else if msg.getNode() = "watched-button"
if content.watched
UnmarkItemWatched(movie_id)
if movie.watched
UnmarkItemWatched(movie.id)
else
MarkItemWatched(movie_id)
MarkItemWatched(movie.id)
end if
content.watched = not content.watched
movie.watched = not movie.watched
else if msg.getNode() = "favorite-button"
if content.favorite
UnmarkItemFavorite(movie_id)
if movie.favorite
UnmarkItemFavorite(movie.id)
else
MarkItemFavorite(movie_id)
MarkItemFavorite(movie.id)
end if
content.favorite = not content.favorite
movie.favorite = not movie.favorite
end if
else
print msg
@ -363,12 +366,12 @@ sub ShowTVShowOptions(library)
return
else if nodeEventQ(msg, "itemSelected")
target = getMsgRowTarget(msg)
ShowTVShowDetails(target.showID)
ShowTVShowDetails(target)
end if
end while
end sub
sub ShowTVShowDetails(show_id)
sub ShowTVShowDetails(series)
port = CreateObject("roMessagePort")
screen = CreateObject("roSGScreen")
screen.setMessagePort(port)
@ -378,9 +381,10 @@ sub ShowTVShowDetails(show_id)
themeScene(scene)
scene.itemData = ItemMetaData(show_id)
series = ItemMetaData(series.id)
scene.itemData = series
scene.findNode("description").findNode("buttons").setFocus(true)
scene.seasonData = TVSeasons(show_id)
scene.seasonData = TVSeasons(series.id)
scene.findNode("description").findNode("buttons").setFocus(true)
@ -395,14 +399,13 @@ sub ShowTVShowDetails(show_id)
return
else if nodeEventQ(msg, "buttonSelected")
' What button could we even be watching yet
print "HELLO"
else if nodeEventQ(msg, "rowItemSelected")
' Assume for now it's a season being selected
season_list = msg.getRoSGNode()
item = msg.getData()
season = season_list.content.getChild(item[0]).getChild(item[1])
ShowTVSeasonEpisodes(show_id, season.full_data.id)
ShowTVSeasonEpisodes(series, season)
else
print msg
print type(msg)
@ -410,7 +413,7 @@ sub ShowTVShowDetails(show_id)
end while
end sub
sub ShowTVSeasonEpisodes(show_id, season_id)
sub ShowTVSeasonEpisodes(series, season)
port = CreateObject("roMessagePort")
screen = CreateObject("roSGScreen")
screen.setMessagePort(port)
@ -420,9 +423,9 @@ sub ShowTVSeasonEpisodes(show_id, season_id)
themeScene(scene)
scene.showData = ItemMetaData(show_id)
scene.seasonData = TVSeasons(show_id)
scene.episodeData = TVEpisodes(show_id, season_id)
scene.showData = ItemMetaData(series.id)
scene.seasonData = TVSeasons(series.id)
scene.episodeData = TVEpisodes(series.id, season.id)
scene.findNode("TVEpisodeSelect").observeField("rowItemSelected", port)
@ -435,7 +438,7 @@ sub ShowTVSeasonEpisodes(show_id, season_id)
item = msg.getData()
episode = episode_list.content.getChild(item[0]).getChild(item[1])
ShowVideoPlayer(episode.full_data.id)
ShowVideoPlayer(episode.id)
else
print msg
print type(msg)
@ -566,7 +569,7 @@ sub ShowSearchOptions(query)
target = getMsgRowTarget(msg)
' TODO - swap this based on target.mediatype
' types: [ Episode, Movie, Audio, Person, Studio, MusicArtist ]
ShowMovieDetails(target.mediaID)
ShowMovieDetails(target)
else
print msg
print msg.getField()

View File

@ -17,6 +17,7 @@ end function
function SearchMedia(query as String)
resp = APIRequest("Search/Hints", {"searchTerm": query})
data = getJson(resp)
results = []
for each item in data.SearchHints
if item.type = "Movie"
item.posterURL = ImageURL(item.id)
@ -25,7 +26,12 @@ function SearchMedia(query as String)
else if item.type = "Episode"
item.posterURL = ImageURL(item.id)
end if
tmp = CreateObject("roSGNode", "SearchData")
tmp.json = item
results.push(tmp)
end for
data.SearchHints = results
return data
end function
@ -48,11 +54,15 @@ function ItemList(library_id=invalid as String, params={})
if item.type = "Movie"
tmp = CreateObject("roSGNode", "MovieData")
tmp.full_data = item
tmp.json = item
results.push(tmp)
else if item.type = "Series"
tmp = CreateObject("roSGNode", "SeriesData")
tmp.full_data = item
tmp.json = item
results.push(tmp)
else if item.type = "Cllection"
tmp = CreateObject("roSGNode", "CollectionData")
tmp.json = item
results.push(tmp)
else
print item.type
@ -72,12 +82,16 @@ function ItemMetaData(id as String)
data.posterURL = ImageURL(data.id)
if data.type = "Movie"
tmp = CreateObject("roSGNode", "MovieData")
tmp.full_data = data
tmp.json = data
return tmp
else if data.type = "Series"
tmp = CreateObject("roSGNode", "SeriesData")
tmp.full_data = data
tmp.json = data
return tmp
else if item.type = "Cllection"
tmp = CreateObject("roSGNode", "CollectionData")
tmp.json = item
results.push(tmp)
else
print data.type
' Return json if we don't know what it is
@ -92,9 +106,14 @@ function TVSeasons(id as String)
resp = APIRequest(url, {"UserId": get_setting("active_user")})
data = getJson(resp)
results = []
for each item in data.Items
item.posterURL = ImageURL(item.id)
tmp = CreateObject("roSGNode", "TVEpisodeData")
tmp.json = item
results.push(tmp)
end for
data.Items = results
return data
end function
@ -103,9 +122,14 @@ function TVEpisodes(show_id as String, season_id as String)
resp = APIRequest(url, {"seasonId": season_id, "UserId": get_setting("active_user")})
data = getJson(resp)
results = []
for each item in data.Items
item.posterURL = ImageURL(item.id)
tmp = CreateObject("roSGNode", "TVEpisodeData")
tmp.json = item
results.push(tmp)
end for
data.Items = results
return data
end function

View File

@ -1,12 +1,13 @@
' "Q" stands for "Question mark" since nodeEvent? wasn't acceptable
' Probably needs a better name, but unique for now
function nodeEventQ(msg, field) as boolean
function nodeEventQ(msg, field as string) as boolean
return type(msg) = "roSGNodeEvent" and msg.getField() = field
end function
function getMsgRowTarget(msg, subnode=invalid) as object
function getMsgRowTarget(msg, subnode="" as string) as object
node = msg.getRoSGNode()
if subnode <> invalid
' Subnode allows for handling alias messages
if subnode <> ""
node = node.findNode(subnode)
end if
coords = node.rowItemSelected