2023-10-03 16:11:25 +00:00
|
|
|
import "pkg:/source/api/Image.bs"
|
|
|
|
import "pkg:/source/api/baserequest.bs"
|
|
|
|
import "pkg:/source/utils/config.bs"
|
|
|
|
import "pkg:/source/utils/misc.bs"
|
2023-10-17 01:33:06 +00:00
|
|
|
import "pkg:/source/api/sdk.bs"
|
2023-05-03 21:21:04 +00:00
|
|
|
|
2020-02-23 04:47:00 +00:00
|
|
|
sub init()
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.optionsAvailable = false
|
2022-04-24 03:49:42 +00:00
|
|
|
|
|
|
|
m.rows = m.top.findNode("picker")
|
2022-06-09 20:51:04 +00:00
|
|
|
m.poster = m.top.findNode("seasonPoster")
|
2023-10-17 01:33:06 +00:00
|
|
|
m.shuffle = m.top.findNode("shuffle")
|
|
|
|
m.extras = m.top.findNode("extras")
|
2022-06-09 20:51:04 +00:00
|
|
|
m.tvEpisodeRow = m.top.findNode("tvEpisodeRow")
|
|
|
|
|
2022-12-10 22:09:08 +00:00
|
|
|
m.unplayedCount = m.top.findNode("unplayedCount")
|
|
|
|
m.unplayedEpisodeCount = m.top.findNode("unplayedEpisodeCount")
|
2022-06-09 20:51:04 +00:00
|
|
|
|
2022-04-24 03:49:42 +00:00
|
|
|
m.rows.observeField("doneLoading", "updateSeason")
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub setSeasonLoading()
|
|
|
|
m.top.overhangTitle = tr("Loading...")
|
2020-02-23 04:47:00 +00:00
|
|
|
end sub
|
|
|
|
|
2023-10-17 01:33:06 +00:00
|
|
|
' Updates the visibility of the Extras button based on if this season has any extra features
|
2023-10-15 02:21:08 +00:00
|
|
|
sub setExtraButtonVisibility()
|
2023-10-17 01:33:06 +00:00
|
|
|
if isValid(m.top.extrasObjects) and isValidAndNotEmpty(m.top.extrasObjects.items)
|
2023-10-26 03:19:45 +00:00
|
|
|
m.extras.visible = true
|
2023-10-15 02:21:08 +00:00
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
2022-04-24 03:49:42 +00:00
|
|
|
sub updateSeason()
|
2023-06-01 12:43:27 +00:00
|
|
|
if m.global.session.user.settings["ui.tvshows.disableUnwatchedEpisodeCount"] = false
|
2023-03-09 19:35:29 +00:00
|
|
|
if isValid(m.top.seasonData) and isValid(m.top.seasonData.UserData) and isValid(m.top.seasonData.UserData.UnplayedItemCount)
|
2023-02-04 23:16:36 +00:00
|
|
|
if m.top.seasonData.UserData.UnplayedItemCount > 0
|
|
|
|
m.unplayedCount.visible = true
|
|
|
|
m.unplayedEpisodeCount.text = m.top.seasonData.UserData.UnplayedItemCount
|
|
|
|
end if
|
2022-12-10 22:41:22 +00:00
|
|
|
end if
|
2022-12-10 22:09:08 +00:00
|
|
|
end if
|
|
|
|
|
2022-06-09 20:51:04 +00:00
|
|
|
imgParams = { "maxHeight": 450, "maxWidth": 300 }
|
|
|
|
m.poster.uri = ImageURL(m.top.seasonData.Id, "Primary", imgParams)
|
2023-10-17 01:33:06 +00:00
|
|
|
m.shuffle.visible = true
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.overhangTitle = m.top.seasonData.SeriesName + " - " + m.top.seasonData.name
|
2020-02-23 04:47:00 +00:00
|
|
|
end sub
|
2020-12-08 20:05:22 +00:00
|
|
|
|
2023-11-18 14:38:36 +00:00
|
|
|
' get the currently focused item
|
|
|
|
function getFocusedItem() as dynamic
|
2023-11-20 03:04:17 +00:00
|
|
|
if not isValid(m.top.focusedChild) or not isValid(m.top.focusedChild.focusedChild)
|
2023-11-18 14:38:36 +00:00
|
|
|
return invalid
|
|
|
|
end if
|
|
|
|
|
2023-11-20 03:04:17 +00:00
|
|
|
focusedChild = m.top.focusedChild.focusedChild
|
|
|
|
if not isValid(focusedChild.content) then return invalid
|
|
|
|
m.top.lastFocus = focusedChild
|
|
|
|
|
2023-11-18 14:38:36 +00:00
|
|
|
if isValidAndNotEmpty(focusedChild.rowItemFocused)
|
|
|
|
itemToPlay = focusedChild.content.getChild(focusedChild.rowItemFocused[0]).getChild(0)
|
|
|
|
if isValid(itemToPlay) and isValidAndNotEmpty(itemToPlay.id)
|
|
|
|
return itemToPlay
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
|
|
|
return invalid
|
|
|
|
end function
|
|
|
|
|
2023-10-17 01:33:06 +00:00
|
|
|
' Handle navigation input from the remote and act on it
|
2020-12-08 20:05:22 +00:00
|
|
|
function onKeyEvent(key as string, press as boolean) as boolean
|
2023-05-21 03:24:52 +00:00
|
|
|
if key = "left" and m.tvEpisodeRow.hasFocus()
|
2023-10-17 01:33:06 +00:00
|
|
|
m.shuffle.setFocus(true)
|
2023-02-25 16:43:36 +00:00
|
|
|
return true
|
|
|
|
end if
|
|
|
|
|
2023-10-26 03:19:45 +00:00
|
|
|
if key = "right" and (m.shuffle.hasFocus() or m.extras.hasFocus())
|
2022-06-09 20:51:04 +00:00
|
|
|
m.tvEpisodeRow.setFocus(true)
|
|
|
|
return true
|
|
|
|
end if
|
|
|
|
|
2023-10-26 17:06:29 +00:00
|
|
|
if m.extras.visible and key = "up" and m.extras.hasFocus()
|
2023-10-17 01:33:06 +00:00
|
|
|
m.shuffle.setFocus(true)
|
2023-10-15 02:21:08 +00:00
|
|
|
return true
|
|
|
|
end if
|
2023-02-25 16:43:36 +00:00
|
|
|
|
2023-10-26 17:06:29 +00:00
|
|
|
if m.extras.visible and key = "down" and m.shuffle.hasFocus()
|
2023-10-26 03:19:45 +00:00
|
|
|
m.extras.setFocus(true)
|
2023-10-15 02:21:08 +00:00
|
|
|
return true
|
|
|
|
end if
|
|
|
|
|
2023-11-18 14:38:36 +00:00
|
|
|
if key = "OK"
|
|
|
|
if m.tvEpisodeRow.isInFocusChain()
|
|
|
|
focusedItem = getFocusedItem()
|
|
|
|
if isValid(focusedItem)
|
|
|
|
m.top.selectedItem = focusedItem
|
|
|
|
end if
|
|
|
|
return true
|
|
|
|
end if
|
|
|
|
|
2023-10-17 01:33:06 +00:00
|
|
|
if m.shuffle.hasFocus()
|
2023-02-25 16:43:36 +00:00
|
|
|
episodeList = m.rows.getChild(0).objects.items
|
|
|
|
|
|
|
|
for i = 0 to episodeList.count() - 1
|
|
|
|
j = Rnd(episodeList.count() - 1)
|
|
|
|
temp = episodeList[i]
|
|
|
|
episodeList[i] = episodeList[j]
|
|
|
|
episodeList[j] = temp
|
|
|
|
end for
|
|
|
|
|
|
|
|
m.global.queueManager.callFunc("set", episodeList)
|
|
|
|
m.global.queueManager.callFunc("playQueue")
|
|
|
|
return true
|
|
|
|
end if
|
2023-10-15 02:21:08 +00:00
|
|
|
|
2023-10-17 01:33:06 +00:00
|
|
|
if m.extras.visible and m.extras.hasFocus()
|
|
|
|
if LCase(m.extras.text.trim()) = LCase(tr("Extras"))
|
|
|
|
m.extras.text = tr("Episodes")
|
2023-10-15 02:21:08 +00:00
|
|
|
m.top.objects = m.top.extrasObjects
|
|
|
|
else
|
2023-10-17 01:33:06 +00:00
|
|
|
m.extras.text = tr("Extras")
|
2023-10-15 02:21:08 +00:00
|
|
|
m.top.objects = m.top.episodeObjects
|
|
|
|
end if
|
|
|
|
end if
|
2022-06-09 20:51:04 +00:00
|
|
|
end if
|
|
|
|
|
2023-11-18 14:38:36 +00:00
|
|
|
if key = "play"
|
|
|
|
focusedItem = getFocusedItem()
|
|
|
|
if isValid(focusedItem)
|
|
|
|
m.top.quickPlayNode = focusedItem
|
2021-07-09 20:08:32 +00:00
|
|
|
end if
|
2023-11-18 14:38:36 +00:00
|
|
|
return true
|
2020-12-08 20:05:22 +00:00
|
|
|
end if
|
2023-11-18 14:38:36 +00:00
|
|
|
|
|
|
|
return false
|
2020-12-08 20:05:22 +00:00
|
|
|
end function
|