Skip to content

Commit

Permalink
[Part 2] Innertube (#513)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
iBicha and github-action linter authored Dec 22, 2024
1 parent 9f3eee9 commit bed8223
Show file tree
Hide file tree
Showing 16 changed files with 443 additions and 36 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Built-in Playlet backend, which supports channels, playlists, and search
- This backend is not finished, and provides the bare minimum to watch videos.
- More features to come.
- This backend is experimental, and has a few missing features.
- To use it, set the Invidious instance to an empty string.

### Fixed

Expand Down
8 changes: 7 additions & 1 deletion playlet-lib/src/components/ChannelView/ChannelView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ function OnContentSet() as void

' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.authorLabel.text = content._author
m.subCountLabel.text = content.subCountText

subCountText = content.authorSubTitle
if StringUtils.IsNullOrEmpty(subCountText)
subCountText = content.subCountText
end if
m.subCountLabel.text = subCountText

m.banner.uri = content.banner
if StringUtils.IsNullOrEmpty(content.thumbnail)
m.thumbnail.uri = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<!-- NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation -->
<field id="_author" type="string" />
<field id="authorId" type="string" />
<field id="authorSubTitle" type="string" />
<field id="banner" type="string" />
<field id="channelHandle" type="string" />
<field id="description" type="string" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
<field id="videoCountText" type="string" />
<field id="viewCount" type="integer" />
<field id="viewCountText" type="string" />
<field id="statsText" type="string" />
</interface>
</component>
23 changes: 23 additions & 0 deletions playlet-lib/src/components/MainScene.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "pkg:/components/EcpArgs.bs"
import "pkg:/components/parts/AutoBind/AutoBind.part.bs"
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/source/utils/LoadingScreen.bs"
import "pkg:/source/utils/Locale.bs"

function Init()
m.scene = m.top.getScene()
Expand All @@ -18,6 +19,7 @@ function MainSceneContainerChanged()
InitEcpArgs()
m.scene.signalBeacon("AppLaunchComplete")
CopyLoadingMessagesToCache()
ShowAnnouncement()
end function

function StartWebServer()
Expand All @@ -30,3 +32,24 @@ function StartWebServer()
m.dialServer = m.top.findNode("DialServer")
m.dialServer@.StartServer()
end function

function ShowAnnouncement()
title = "Announcement - Playlet backend"
message = [
"An experimental built-in backend has been added to Playlet."
"This allows you to access YouTube content without the need for an Invidious instance."
"To use it, go to the Settings > Invidious > Instance and set the field to empty (Edit, and delete the url)."
"Please note that it's missing some features and may not work as expected."
"Thank you for using Playlet!"
]

buttons = [Tr(Locale.Buttons.OK)]
dialog = CreateObject("roSGNode", "SimpleDialog")
dialog.title = title
dialog.message = message
dialog.buttons = buttons
deviceInfo = CreateObject("roDeviceInfo")
displaySize = deviceInfo.GetDisplaySize()
dialog.width = displaySize.w - 180
m.top.getScene().dialog = dialog
end function
24 changes: 24 additions & 0 deletions playlet-lib/src/components/MainScene.transpiled.brs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'import "pkg:/components/parts/AutoBind/AutoBind.part.bs"
'import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
'import "pkg:/source/utils/LoadingScreen.bs"
'import "pkg:/source/utils/Locale.bs"

function Init()
InitializeBindings() ' auto-generated!
Expand All @@ -19,6 +20,7 @@ function MainSceneContainerChanged()
InitEcpArgs()
m.scene.signalBeacon("AppLaunchComplete")
CopyLoadingMessagesToCache()
ShowAnnouncement()
end function

function StartWebServer()
Expand All @@ -29,4 +31,26 @@ function StartWebServer()
m.dialServer = m.top.findNode("DialServer")
m.dialServer.callfunc("StartServer", invalid)
end function

function ShowAnnouncement()
title = "Announcement - Playlet backend"
message = [
"An experimental built-in backend has been added to Playlet."
"This allows you to access YouTube content without the need for an Invidious instance."
"To use it, go to the Settings > Invidious > Instance and set the field to empty (Edit, and delete the url)."
"Please note that it's missing some features and may not work as expected."
"Thank you for using Playlet!"
]
buttons = [
Tr("OK")
]
dialog = CreateObject("roSGNode", "SimpleDialog")
dialog.title = title
dialog.message = message
dialog.buttons = buttons
deviceInfo = CreateObject("roDeviceInfo")
displaySize = deviceInfo.GetDisplaySize()
dialog.width = displaySize.w - 180
m.top.getScene().dialog = dialog
end function
'//# sourceMappingURL=./MainScene.brs.map
9 changes: 7 additions & 2 deletions playlet-lib/src/components/PlaylistView/PlaylistView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ function OnContentSet() as void
if content.playlistId.StartsWith("RD")
m.subtitleLabel.text = ""
else
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.subtitleLabel.text = `${content._author}${content.videoCountText}${content.viewCountText}`
statsText = content.statsText
if statsText.Len() > 0
m.subtitleLabel.text = statsText
else
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.subtitleLabel.text = `${content._author}${content.videoCountText}${content.viewCountText}`
end if
end if
m.updatedLabel.text = content.updatedText
m.descriptionLabel.text = content.description
Expand Down
Loading

0 comments on commit bed8223

Please sign in to comment.