diff --git a/components/tvshows/TVEpisodes.brs b/components/tvshows/TVEpisodes.brs index 8872ffc37..69167a734 100644 --- a/components/tvshows/TVEpisodes.brs +++ b/components/tvshows/TVEpisodes.brs @@ -9,6 +9,7 @@ sub init() m.rows = m.top.findNode("picker") m.poster = m.top.findNode("seasonPoster") m.Shuffle = m.top.findNode("Shuffle") + m.Extras = m.top.findNode("Extras") m.tvEpisodeRow = m.top.findNode("tvEpisodeRow") m.unplayedCount = m.top.findNode("unplayedCount") @@ -21,6 +22,12 @@ sub setSeasonLoading() m.top.overhangTitle = tr("Loading...") end sub +sub setExtraButtonVisibility() + if isValid(m.top.extrasObjects) and (not m.top.extrasObjects.items.IsEmpty()) + m.Extras.visible = true + end if +end sub + sub updateSeason() if m.global.session.user.settings["ui.tvshows.disableUnwatchedEpisodeCount"] = false if isValid(m.top.seasonData) and isValid(m.top.seasonData.UserData) and isValid(m.top.seasonData.UserData.UnplayedItemCount) @@ -45,13 +52,23 @@ function onKeyEvent(key as string, press as boolean) as boolean return true end if - if key = "right" and (m.Shuffle.hasFocus()) + if key = "right" and (m.Shuffle.hasFocus() or m.Extras.hasFocus()) m.tvEpisodeRow.setFocus(true) return true end if - if key = "OK" or key = "play" + showExtras = isValid(m.top.extrasObjects) and (not m.top.extrasObjects.IsEmpty()) + if showExtras and key = "up" and (m.Extras.hasFocus()) + m.Shuffle.setFocus(true) + return true + end if + if showExtras and key = "down" and (m.Shuffle.hasFocus()) + m.Extras.setFocus(true) + return true + end if + + if key = "OK" or key = "play" if m.Shuffle.hasFocus() episodeList = m.rows.getChild(0).objects.items @@ -66,6 +83,16 @@ function onKeyEvent(key as string, press as boolean) as boolean m.global.queueManager.callFunc("playQueue") return true end if + + if showExtras and m.Extras.hasFocus() + if m.Extras.text.trim() = "Extras" + m.Extras.text = "Episodes" + m.top.objects = m.top.extrasObjects + else + m.Extras.text = "Extras" + m.top.objects = m.top.episodeObjects + end if + end if end if focusedChild = m.top.focusedChild.focusedChild @@ -81,7 +108,6 @@ function onKeyEvent(key as string, press as boolean) as boolean m.top.lastFocus = focusedChild itemToPlay = focusedChild.content.getChild(focusedChild.rowItemFocused[0]).getChild(0) if isValid(itemToPlay) and isValid(itemToPlay.id) and itemToPlay.id <> "" - itemToPlay.type = "Episode" m.top.quickPlayNode = itemToPlay end if handled = true diff --git a/components/tvshows/TVEpisodes.xml b/components/tvshows/TVEpisodes.xml index 004c07fb9..8492abc67 100644 --- a/components/tvshows/TVEpisodes.xml +++ b/components/tvshows/TVEpisodes.xml @@ -7,6 +7,7 @@ + @@ -14,5 +15,7 @@ + + \ No newline at end of file diff --git a/settings/settings.json b/settings/settings.json index 422174741..6e5a2792b 100644 --- a/settings/settings.json +++ b/settings/settings.json @@ -10,7 +10,6 @@ "type": "bool", "default": "false" } - ] }, { @@ -126,7 +125,6 @@ ] } ] - }, { "title": "Video Codec Support", @@ -362,4 +360,4 @@ } ] } -] +] \ No newline at end of file diff --git a/source/ShowScenes.brs b/source/ShowScenes.brs index 48a1853db..a44a8427c 100644 --- a/source/ShowScenes.brs +++ b/source/ShowScenes.brs @@ -743,6 +743,9 @@ function CreateSeasonDetailsGroup(series as object, season as object) as dynamic m.global.sceneManager.callFunc("pushScene", group) group.seasonData = seasonMetaData.json group.objects = TVEpisodes(series.id, season.id) + group.episodeObjects = group.objects + group.extrasObjects = TVSeasonExtras(season.id) + ' watch for button presses group.observeField("episodeSelected", m.port) group.observeField("quickPlayNode", m.port) @@ -770,6 +773,9 @@ function CreateSeasonDetailsGroupByID(seriesID as string, seasonID as string) as m.global.sceneManager.callFunc("pushScene", group) group.seasonData = seasonMetaData.json group.objects = TVEpisodes(seriesID, seasonID) + group.episodeObjects = group.objects + group.extrasObjects = TVSeasonExtras(seasonID) + ' watch for button presses group.observeField("episodeSelected", m.port) group.observeField("quickPlayNode", m.port) diff --git a/source/api/Items.brs b/source/api/Items.brs index a3d376471..33a384018 100644 --- a/source/api/Items.brs +++ b/source/api/Items.brs @@ -445,6 +445,41 @@ function TVEpisodes(show_id as string, season_id as string) as dynamic return data end function +function TVSeasonExtras(season_id as string) as dynamic + url = Substitute("/Users/{0}/Items/{1}/SpecialFeatures", m.global.session.user.id, season_id) + resp = APIRequest(url) + + ' validate data + data = getJson(resp) + if data = invalid then return invalid + + results = [] + for each item in data + imgParams = { "maxWidth": 400, "maxheight": 250 } + tmp = CreateObject("roSGNode", "TVEpisodeData") + tmp.image = PosterImage(item.id, imgParams) + if tmp.image <> invalid + tmp.image.posterDisplayMode = "scaleToZoom" + end if + tmp.json = item + + ' Force item type to Video so episode auto queue is not attempted + tmp.type = "Video" + tmpMetaData = ItemMetaData(item.id) + + ' Validate meta data + if tmpMetaData <> invalid and tmpMetaData.overview <> invalid + tmp.overview = tmpMetaData.overview + end if + results.push(tmp) + end for + + ' Build that data format that the TVEpisodeRow expects + extrasData = { Items: [] } + extrasData.Items = results + return extrasData +end function + function TVEpisodeShuffleList(show_id as string) url = Substitute("Shows/{0}/Episodes", show_id) resp = APIRequest(url, {