Add playlist updated field

This commit is contained in:
Brahim Hadriche committed 2023-09-11 13:47:44 -04:00
1 parent b7fe0feb94
commit ae82ad4b28
8 files changed
+68 -16

No files matched your search

+6
View File
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- A field to indicate when a playlist was last updated
## [0.11.0] - 2023-09-10
This version went through a major refactor, which resulted in a different arcitecture of the app to support new features, the rewrite of many pieces, as well as new features.
@@ -29,5 +29,7 @@
<field id="videoCountText" type="string" />
<field id="viewCount" type="integer" />
<field id="viewCountText" type="string" />
<field id="updated" type="integer" />
<field id="updatedText" type="string" />
</interface>
</component>
-3
View File
@@ -61,9 +61,6 @@
invidious="bind:../Invidious"
preferences="bind:../Preferences"
playQueue="bind:../PlayQueue" />
<!-- Inherits from WebServer
<WebSocketServer id="WebSocketServer" webserver="ref:../WebServer" /> -->
</AppController>
</children>
</component>
@@ -17,6 +17,7 @@ function Init()
m.backgroundSmall = m.top.findNode("backgroundSmall")
m.titleLabel = m.top.findNode("titleLabel")
m.subtitleLabel = m.top.findNode("subtitleLabel")
m.updatedLabel = m.top.findNode("updatedLabel")
m.descriptionLabel = m.top.findNode("descriptionLabel")
m.list = m.top.findNode("list")
end function
@@ -43,6 +44,7 @@ function OnContentSet() as void
m.titleLabel.text = content.title
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.subtitleLabel.text = `${content._author} • ${content.videoCountText} • ${content.viewCountText}`
m.updatedLabel.text = content.updatedText
m.descriptionLabel.text = content.description
' TODO:P2 cross fade
@@ -22,7 +22,7 @@
height="720"
blendColor="0x323232">
<LayoutGroup
itemSpacings="[5,20]"
itemSpacings="[5,5,20]"
translation="[65,90]">
<Label
id="titleLabel"
@@ -35,6 +35,10 @@
id="subtitleLabel"
width="500"
font="font:SmallestBoldSystemFont" />
<Label
id="updatedLabel"
width="500"
font="font:SmallestSystemFont" />
<Label
id="descriptionLabel"
width="500"
@@ -70,6 +70,8 @@ namespace InvidiousContent
node.videoCountText = PlaylistGetVideoCountText(item)
SetIfExists(node, "viewCount", item, "viewCount")
node.viewCountText = PlaylistGetViewCountText(item)
SetIfExists(node, "updated", item, "updated")
node.updatedText = PlaylistGetUpdatedText(item)
if item.videos <> invalid
childCount = node.getChildCount()
@@ -208,4 +210,42 @@ namespace InvidiousContent
return VideoGetViewCountText(playlistItem)
end function
function PlaylistGetUpdatedText(playlistItem as object) as string
updated = playlistItem.updated
if not IsInt(updated)
return ""
end if
span = TimeUtils.Now().AsSeconds() - updated
if span < 1
return ""
end if
count = ""
total_days = span \ 86400
if total_days > 365
years = total_days \ 365
count = years > 1 ? `${years} years` : "1 year"
else if total_days > 30
months = total_days \ 30
count = months > 1 ? `${months} months` : "1 month"
else if total_days > 7
weeks = total_days \ 7
count = weeks > 1 ? `${weeks} weeks` : "1 week"
else if total_days > 1
count = `${total_days} days`
else if span > 3600
hours = span \ 3600
count = hours > 1 ? `${hours} hours` : "1 hour"
else if span > 60
minutes = span \ 60
count = minutes > 1 ? `${minutes} minutes` : "1 minute"
else
count = span > 1 ? `${span} seconds` : "1 second"
end if
if StringUtils.IsNullOrEmpty(count)
return ""
end if
return `Updated ${count} ago`
end function
end namespace
@@ -3,6 +3,7 @@ import "pkg:/source/utils/Types.bs"
function Init()
m.titleLabel = m.top.FindNode("titleLabel")
m.authorLabel = m.top.FindNode("authorLabel")
m.updatedLabel = m.top.FindNode("updatedLabel")
m.videoCountRect = m.top.FindNode("videoCountRect")
m.videoCountLabel = m.top.FindNode("videoCountLabel")
m.thumbnail = m.top.FindNode("thumbnail")
@@ -19,6 +20,7 @@ function OnContentSet() as void
m.titleLabel.text = content.title
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.authorLabel.text = content._author
m.updatedLabel.text = content.updatedText
m.thumbnail.uri = content.thumbnail
@@ -7,30 +7,26 @@
</interface>
<children>
<LayoutGroup
itemSpacings="[24,5]"
>
itemSpacings="[24,5,5]">
<Poster
id="thumbnail"
loadDisplayMode="scaleToZoom"
width="350"
height="196"
>
height="196">
<Rectangle
id="videoCountRect"
width="60"
height="26"
color="0x000000"
opacity="0.8"
translation="[290, 162]"
>
translation="[290, 162]">
<Label
height="26"
id="videoCountLabel"
horizAlign="center"
vertAlign="center"
font="font:SmallestSystemFont"
translation="[8, 0]"
/>
translation="[8, 0]" />
</Rectangle>
</Poster>
@@ -39,14 +35,17 @@
width="350"
font="font:SmallestBoldSystemFont"
maxLines="2"
wrap="true"
/>
wrap="true" />
<Label
id="authorLabel"
width="350"
height="25"
font="font:SmallestSystemFont"
/>
font="font:SmallestSystemFont" />
<Label
id="updatedLabel"
width="350"
height="25"
font="font:SmallestSystemFont" />
</LayoutGroup>
</children>
</component>