jf-roku/components/data/HomeData.bs

137 lines
5.4 KiB
Plaintext
Raw Normal View History

import "pkg:/source/api/baserequest.bs"
import "pkg:/source/utils/config.bs"
import "pkg:/source/api/Image.bs"
2019-05-03 12:48:59 +00:00
sub setData()
' We keep json around just as a reference,
' but ideally everything should be going through one of the interfaces
datum = m.top.json
m.top.id = datum.id
m.top.name = datum.name
m.top.type = datum.type
if datum.CollectionType = invalid
m.top.CollectionType = datum.type
else
m.top.CollectionType = datum.CollectionType
end if
' Set appropriate Images for Wide and Tall based on type
2021-07-09 20:08:32 +00:00
if datum.type = "CollectionFolder" or datum.type = "UserView"
params = { "Tag": datum.ImageTags.Primary, "maxHeight": 261, "maxWidth": 464 }
m.top.thumbnailURL = ImageURL(datum.id, "Primary", params)
m.top.widePosterUrl = m.top.thumbnailURL
' Add Icon URLs for display if there is no Poster
if datum.CollectionType = "livetv"
2020-11-23 17:25:42 +00:00
m.top.iconUrl = "pkg:/images/media_type_icons/live_tv_white.png"
else if datum.CollectionType = "folders"
m.top.iconUrl = "pkg:/images/media_type_icons/folder_white.png"
end if
2024-02-08 16:50:05 +00:00
else if datum.type = "Episode" or LCase(datum.type) = "recording" or datum.type = "MusicVideo"
m.top.isWatched = datum.UserData.Played
imgParams = {}
imgParams.Append({ "maxHeight": 261 })
imgParams.Append({ "maxWidth": 464 })
if datum.ImageTags.Primary <> invalid
param = { "Tag": datum.ImageTags.Primary }
imgParams.Append(param)
end if
m.top.thumbnailURL = ImageURL(datum.id, "Primary", imgParams)
' Add Wide Poster (Series Backdrop)
if datum.ParentThumbImageTag <> invalid
imgParams["Tag"] = datum.ParentThumbImageTag
m.top.widePosterUrl = ImageURL(datum.ParentThumbItemId, "Thumb", imgParams)
else if datum.ParentBackdropImageTags <> invalid
imgParams["Tag"] = datum.ParentBackdropImageTags[0]
m.top.widePosterUrl = ImageURL(datum.ParentBackdropItemId, "Backdrop", imgParams)
else if datum.ImageTags.Primary <> invalid
imgParams["Tag"] = datum.SeriesPrimaryImageTag
m.top.widePosterUrl = ImageURL(datum.id, "Primary", imgParams)
end if
else if datum.type = "Series"
imgParams = { "maxHeight": 261 }
imgParams.Append({ "maxWidth": 464 })
m.top.posterURL = ImageURL(datum.id, "Primary", imgParams)
' Add Wide Poster (Series Backdrop)
if datum.ImageTags <> invalid and datum.imageTags.Thumb <> invalid
imgParams["Tag"] = datum.imageTags.Thumb
m.top.widePosterUrl = ImageURL(datum.Id, "Thumb", imgParams)
else if datum.BackdropImageTags <> invalid
imgParams["Tag"] = datum.BackdropImageTags[0]
m.top.widePosterUrl = ImageURL(datum.Id, "Backdrop", imgParams)
end if
2023-11-13 14:16:00 +00:00
else if datum.type = "Movie"
m.top.isWatched = datum.UserData.Played
imgParams = {}
imgParams.Append({ "maxHeight": 261 })
imgParams.Append({ "maxWidth": 175 })
if datum.ImageTags.Primary <> invalid
param = { "Tag": datum.ImageTags.Primary }
imgParams.Append(param)
end if
m.top.posterURL = ImageURL(datum.id, "Primary", imgParams)
' For wide image, use backdrop
imgParams["maxWidth"] = 464
if datum.ImageTags <> invalid and datum.imageTags.Thumb <> invalid
imgParams["Tag"] = datum.imageTags.Thumb
m.top.thumbnailUrl = ImageURL(datum.Id, "Thumb", imgParams)
else if datum.BackdropImageTags[0] <> invalid
imgParams["Tag"] = datum.BackdropImageTags[0]
m.top.thumbnailUrl = ImageURL(datum.id, "Backdrop", imgParams)
end if
2023-11-13 14:16:00 +00:00
else if datum.type = "Video"
m.top.isWatched = datum.UserData.Played
imgParams = {
"maxHeight": 261,
"maxWidth": 464
}
if datum.ImageTags <> invalid and datum.ImageTags.Primary <> invalid
imgParams.Append({ "Tag": datum.ImageTags.Primary })
end if
m.top.posterURL = ImageURL(datum.id, "Primary", imgParams)
m.top.thumbnailUrl = m.top.posterURL
else if datum.type = "MusicAlbum"
params = { "Tag": datum.ImageTags.Primary, "maxHeight": 261, "maxWidth": 261 }
m.top.thumbnailURL = ImageURL(datum.id, "Primary", params)
m.top.widePosterUrl = m.top.thumbnailURL
m.top.posterUrl = m.top.thumbnailURL
2021-07-09 20:08:32 +00:00
else if datum.type = "TvChannel" or datum.type = "Channel"
params = { "Tag": datum.ImageTags.Primary, "maxHeight": 261, "maxWidth": 464 }
2020-10-27 17:12:18 +00:00
m.top.thumbnailURL = ImageURL(datum.id, "Primary", params)
m.top.widePosterUrl = m.top.thumbnailURL
2020-11-23 17:25:42 +00:00
m.top.iconUrl = "pkg:/images/media_type_icons/live_tv_white.png"
2023-11-13 14:16:00 +00:00
else if datum.type = "Photo"
params = { "Tag": datum.ImageTags.Primary, "maxHeight": 261, "maxWidth": 464 }
m.top.thumbnailURL = ImageURL(datum.id, "Primary", params)
m.top.widePosterUrl = m.top.thumbnailURL
m.top.posterUrl = m.top.thumbnailURL
else if datum.type = "PhotoAlbum"
params = { "Tag": datum.ImageTags.Primary, "maxHeight": 261, "maxWidth": 464 }
m.top.thumbnailURL = ImageURL(datum.id, "Primary", params)
m.top.widePosterUrl = m.top.thumbnailURL
m.top.posterUrl = m.top.thumbnailURL
end if
2022-05-30 12:57:40 +00:00
end sub