Files
playlet-piped/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.bs
T
Brahim Hadricheandgithub-action linter bed8223e76 [Part 2] Innertube (#513)
* Parse author in videoRenderer

* Parse more fields

* Parse live badge

* playlist video count

* Parse more things

* parse playlists and albums

* More parsing work

* announcement and changelog

* Lint fix

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2024-12-22 16:04:36 -05:00

78 lines
2.3 KiB
Plaintext

import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel")
m.smallestSystemFont = m.top.FindNode("smallestSystemFont")
m.smallestBoldSystemFont = m.top.FindNode("smallestBoldSystemFont")
end function
function OnContentSet() as void
content = m.top.itemContent
if content = invalid
return
end if
m.top.title = content.title
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.top.author = content._author
if content.isUpcoming = true
m.top.viewCountDate = content.premiereTimestampText
else
publishedText = content.publishedText
viewCountText = content.viewCountText
label = publishedText
if publishedText.Len() > 0 and viewCountText.Len() > 0
label += " • "
end if
label += viewCountText
m.top.viewCountDate = label
end if
m.top.thumbnailUri = content.thumbnail
if not StringUtils.IsNullOrEmpty(content.lengthText)
SetDurationLabel(content.lengthText, "#161616FF", 0.8, m.smallestSystemFont)
m.top.durationRectVisible = true
else
if content.isUpcoming = true
SetDurationLabel(Tr(Locale.RowCell.Upcoming), "#161616FF", 0.8, m.smallestBoldSystemFont)
m.top.durationRectVisible = true
else if content.liveNow
SetDurationLabel(Tr(Locale.RowCell.Live), "#CC0000FF", 0.9, m.smallestBoldSystemFont)
m.top.durationRectVisible = true
else
m.top.durationRectVisible = false
end if
end if
end function
function SetDurationLabel(text as string, bgColor as string, bgOpacity as float, font as object) as void
m.top.duration = text
label = m.durationLabel
rect = m.durationRect
if label = invalid or rect = invalid
return
end if
rectParent = rect.getParent()
label.font = font
size = label.localBoundingRect()
rect.width = size.width + 16
rect.translation = [rectParent.width - rect.width, rect.translation[1]]
rect.color = bgColor
rect.opacity = bgOpacity
end function