jf-roku/components/data/MovieData.brs
2022-11-03 20:55:20 -04:00

78 lines
2.3 KiB
Plaintext

sub setFields()
json = m.top.json
m.top.id = json.id
m.top.Title = json.name
m.top.Description = json.overview
m.top.favorite = json.UserData.isFavorite
m.top.watched = json.UserData.played
m.top.Type = "Movie"
if isValid(json.MediaSourceCount) and json.MediaSourceCount > 1
if isValid(json.MediaSources)
m.top.mediaSources = []
for each source in json.MediaSources
m.top.mediaSources.push(source)
end for
end if
end if
if json.ProductionYear <> invalid
m.top.SubTitle = json.ProductionYear
end if
if json.OfficialRating <> invalid and json.OfficialRating <> ""
m.top.Rating = json.OfficialRating
if m.top.SubTitle <> ""
m.top.SubTitle = m.top.SubTitle + " - " + m.top.Rating
else
m.top.SubTitle = m.top.Rating
end if
end if
setPoster()
setContainer()
end sub
sub setPoster()
if m.top.image <> invalid
m.top.posterURL = m.top.image.url
else
if m.top.json.ImageTags.Primary <> invalid
imgParams = { "maxHeight": 440, "maxWidth": 295 }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
else if m.top.json.BackdropImageTags[0] <> invalid
imgParams = { "maxHeight": 440 }
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
else if m.top.json.ParentThumbImageTag <> invalid and m.top.json.ParentThumbItemId <> invalid
imgParams = { "maxHeight": 440, "maxWidth": 295 }
m.top.posterURL = ImageURL(m.top.json.ParentThumbItemId, "Thumb", imgParams)
end if
' Add Backdrop Image
if m.top.json.BackdropImageTags <> invalid
if m.top.json.BackdropImageTags[0] <> invalid
imgParams = { "maxHeight": 720, "maxWidth": 1280 }
m.top.backdropURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
end if
end if
end if
end sub
sub setContainer()
json = m.top.json
if json.mediaSources = invalid then return
if json.mediaSources.count() = 0 then return
m.top.container = json.mediaSources[0].container
if m.top.container = invalid then m.top.container = ""
if m.top.container = "m4v" or m.top.container = "mov"
m.top.container = "mp4"
end if
end sub