components_data_MusicAlbumSongListData.bs
import "pkg:/source/api/baserequest.bs"
import "pkg:/source/api/Image.bs"
import "pkg:/source/utils/backdropUtils.bs"
import "pkg:/source/utils/config.bs"
import "pkg:/source/utils/misc.bs"
sub setFields()
json = m.top.json
m.top.id = json.id
if isValid(json.UserData)
if isValid(json.UserData.isFavorite)
m.top.favorite = json.UserData.isFavorite
end if
end if
m.top.Type = "MusicAlbum"
setPoster()
end sub
sub setPoster()
if isValid(m.top.image)
m.top.posterURL = m.top.image.url
else
if isValid(m.top.json.ImageTags) and isValidAndNotEmpty(m.top.json.ImageTags.Primary)
imgParams = { "maxHeight": 440, "maxWidth": 295, "tag": m.top.json.ImageTags.Primary }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
else if isValid(m.top.json.BackdropImageTags) and isValidAndNotEmpty(m.top.json.BackdropImageTags[0])
imgParams = { "maxHeight": 440, "tag": m.top.json.BackdropImageTags[0] }
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
else if isValidAndNotEmpty(m.top.json.ParentThumbImageTag) and isValid(m.top.json.ParentThumbItemId)
imgParams = { "maxHeight": 440, "maxWidth": 295, "tag": m.top.json.ParentThumbImageTag }
m.top.posterURL = ImageURL(m.top.json.ParentThumbItemId, "Thumb", imgParams)
else
' Set posterURL to empty string when no valid tags exist to prevent 404 requests
m.top.posterURL = ""
end if
end if
' Always set backdrop URL using centralized utility (outside of poster logic)
if isValid(m.top.json)
localDevice = m.global.device
deviceResolution = [localDevice.uiResolution[0], localDevice.uiResolution[1]]
m.top.backdropUrl = getBackdropUrl(m.top.json, deviceResolution)
end if
end sub