2019-05-03 12:48:59 +00:00
|
|
|
sub init()
|
|
|
|
buttons = m.top.findNode("buttons")
|
|
|
|
|
|
|
|
buttons.iconUri = ""
|
|
|
|
|
|
|
|
for each button in buttons.getChildren(-1, 0)
|
|
|
|
button.maxWidth = 350
|
|
|
|
button.minWidth = 350
|
|
|
|
end for
|
|
|
|
end sub
|
|
|
|
|
2019-03-14 17:11:51 +00:00
|
|
|
sub itemContentChanged()
|
2019-05-03 12:48:59 +00:00
|
|
|
' Updates video metadata
|
2019-04-15 00:16:47 +00:00
|
|
|
' TODO - make things use item rather than itemData
|
|
|
|
item = m.top.itemContent
|
|
|
|
itemData = item.json
|
2019-03-14 17:11:51 +00:00
|
|
|
|
|
|
|
m.top.findNode("tvshowPoster").uri = m.top.itemContent.posterURL
|
|
|
|
|
|
|
|
' Handle all "As Is" fields
|
|
|
|
setFieldText("title", itemData.name)
|
|
|
|
setFieldText("releaseYear", itemData.productionYear)
|
|
|
|
setFieldText("officialRating", itemData.officialRating)
|
|
|
|
setFieldText("communityRating", str(itemData.communityRating))
|
|
|
|
setFieldText("overview", itemData.overview)
|
|
|
|
|
2019-10-19 03:38:00 +00:00
|
|
|
|
|
|
|
if type(itemData.RunTimeTicks) = "LongInteger"
|
|
|
|
setFieldText("runtime", stri(getRuntime()) + " mins")
|
|
|
|
end if
|
2019-03-14 17:11:51 +00:00
|
|
|
|
|
|
|
setFieldText("history", getHistory())
|
|
|
|
|
|
|
|
if itemData.genres.count() > 0
|
|
|
|
setFieldText("genres", itemData.genres.join(", "))
|
|
|
|
end if
|
|
|
|
for each person in itemData.people
|
|
|
|
if person.type = "Director"
|
|
|
|
exit for
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
if itemData.taglines.count() > 0
|
|
|
|
setFieldText("tagline", itemData.taglines[0])
|
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
2019-09-24 04:35:26 +00:00
|
|
|
sub setFieldText(field, value)
|
2019-03-14 17:11:51 +00:00
|
|
|
node = m.top.findNode(field)
|
2019-09-24 04:35:26 +00:00
|
|
|
if node = invalid or value = invalid then return
|
|
|
|
|
|
|
|
' Handle non strings... Which _shouldn't_ happen, but hey
|
2019-09-24 04:49:09 +00:00
|
|
|
if type(value) = "roInt" or type(value) = "Integer" then
|
2019-09-24 04:35:26 +00:00
|
|
|
value = str(value)
|
|
|
|
else if type(value) <> "roString" and type(value) <> "String" then
|
|
|
|
value = ""
|
|
|
|
end if
|
2019-03-14 17:11:51 +00:00
|
|
|
|
|
|
|
node.text = value
|
|
|
|
end sub
|
|
|
|
|
2019-05-03 12:48:59 +00:00
|
|
|
function getRuntime() as integer
|
2019-04-15 00:16:47 +00:00
|
|
|
itemData = m.top.itemContent.json
|
2019-03-14 17:11:51 +00:00
|
|
|
|
|
|
|
' A tick is .1ms, so 1/10,000,000 for ticks to seconds,
|
|
|
|
' then 1/60 for seconds to minutess... 1/600,000,000
|
|
|
|
return round(itemData.RunTimeTicks / 600000000.0)
|
|
|
|
end function
|
|
|
|
|
|
|
|
function getEndTime() as string
|
2019-04-15 00:16:47 +00:00
|
|
|
itemData = m.top.itemContent.json
|
2019-03-14 17:11:51 +00:00
|
|
|
|
|
|
|
date = CreateObject("roDateTime")
|
|
|
|
duration_s = int(itemData.RunTimeTicks / 10000000.0)
|
|
|
|
date.fromSeconds(date.asSeconds() + duration_s)
|
|
|
|
date.toLocalTime()
|
|
|
|
|
2020-04-10 08:04:48 +00:00
|
|
|
formatTime(date)
|
2019-03-14 17:11:51 +00:00
|
|
|
end function
|
|
|
|
|
|
|
|
function getHistory() as string
|
2019-04-15 00:16:47 +00:00
|
|
|
itemData = m.top.itemContent.json
|
2019-03-14 17:11:51 +00:00
|
|
|
' Aired Fridays at 9:30 PM on ABC (US)
|
|
|
|
|
|
|
|
airwords = invalid
|
|
|
|
studio = invalid
|
|
|
|
if itemData.status = "Ended"
|
|
|
|
verb = "Aired"
|
|
|
|
else
|
|
|
|
verb = "Airs"
|
|
|
|
end if
|
|
|
|
|
|
|
|
airdays = itemData.airdays
|
|
|
|
airtime = itemData.airtime
|
|
|
|
if airtime <> invalid and airdays.count() = 1
|
|
|
|
airwords = airdays[0] + " at " + airtime
|
2019-05-03 12:48:59 +00:00
|
|
|
end if
|
2019-03-14 17:11:51 +00:00
|
|
|
|
|
|
|
if itemData.studios.count() > 0
|
|
|
|
studio = itemData.studios[0].name
|
|
|
|
end if
|
|
|
|
|
|
|
|
if studio = invalid and airwords = invalid
|
|
|
|
return ""
|
|
|
|
end if
|
|
|
|
|
|
|
|
words = verb
|
|
|
|
if airwords <> invalid
|
|
|
|
words = words + " " + airwords
|
|
|
|
end if
|
|
|
|
if studio <> invalid
|
|
|
|
words = words + " on " + studio
|
|
|
|
end if
|
|
|
|
|
|
|
|
return words
|
|
|
|
end function
|
|
|
|
|
2019-05-03 12:48:59 +00:00
|
|
|
function round(f as float) as integer
|
2019-03-14 17:11:51 +00:00
|
|
|
' BrightScript only has a "floor" round
|
|
|
|
' This compares floor to floor + 1 to find which is closer
|
|
|
|
m = int(f)
|
|
|
|
n = m + 1
|
|
|
|
x = abs(f - m)
|
|
|
|
y = abs(f - n)
|
|
|
|
if y > x
|
|
|
|
return m
|
|
|
|
else
|
|
|
|
return n
|
|
|
|
end if
|
|
|
|
end function
|
|
|
|
|