From dab6dc5bc4852be740d3a3b13badbc4ffe3b2aa0 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Fri, 22 Sep 2023 17:52:53 -0400 Subject: [PATCH] Feature/channel view content (#150) * ChannelView feeds * Fixes for web app * Add request id to error message --- CHANGELOG.md | 6 ++ .../src/components/ChannelView/ChannelView.bs | 73 +++++++++++++++- .../components/ChannelView/ChannelView.xml | 83 +++++++++++-------- .../ContentNode/ChannelContentNode.bs | 1 - .../ContentNode/ChannelContentNode.xml | 9 +- .../ContentNode/FeedContentNode.xml | 3 +- .../Services/Invidious/InvidiousService.bs | 68 ++++++++++++--- .../Invidious/InvidiousToContentNode.bs | 19 +---- .../SponsorBlock/SponsorBlockService.bs | 4 +- .../components/VideoFeed/PaginationType.bs | 4 + .../VideoFeed/VideoRowCell/VideoRowCell.bs | 43 +++++----- .../src/components/VideoFeed/VideoRowList.bs | 6 +- .../VideoFeed/VideoRowListRowContentTask.bs | 18 +++- .../src/config/invidious_video_api.json5 | 56 +++++++++++-- playlet-lib/src/source/services/HttpClient.bs | 2 +- playlet-web/src/lib/Api/InvidiousApi.ts | 9 +- .../src/lib/Screens/Home/ChannelCell.svelte | 82 ++++++++++++++++++ .../src/lib/Screens/Home/ScreenHomeRow.svelte | 55 +++++++++--- .../src/lib/Screens/SearchScreen.svelte | 3 + playlet-web/tsconfig.json | 3 +- 20 files changed, 414 insertions(+), 133 deletions(-) create mode 100644 playlet-lib/src/components/VideoFeed/PaginationType.bs create mode 100644 playlet-web/src/lib/Screens/Home/ChannelCell.svelte diff --git a/CHANGELOG.md b/CHANGELOG.md index dc0ccf82..054d5588 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Playlists, streams, podcasts and related channels to Channel UI + - Pagination supported +- Channels show up in web app (but no UI for channel details yet) + ### Fixed - Another bug where the app crashes if an error happens loading channel info diff --git a/playlet-lib/src/components/ChannelView/ChannelView.bs b/playlet-lib/src/components/ChannelView/ChannelView.bs index 64b26dc9..7fa03d4a 100644 --- a/playlet-lib/src/components/ChannelView/ChannelView.bs +++ b/playlet-lib/src/components/ChannelView/ChannelView.bs @@ -3,12 +3,19 @@ import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/StringUtils.bs" function Init() + m.container = m.top.findNode("container") + m.scrollAnimation = m.top.findNode("scrollAnimation") + m.scrollAnimationInterpolator = m.scrollAnimation.findNode("scrollAnimationInterpolator") + m.banner = m.top.findNode("banner") m.thumbnail = m.top.findNode("thumbnail") m.authorLabel = m.top.findNode("authorLabel") m.rowList = m.top.FindNode("rowList") m.banner.ObserveField("loadStatus", FuncName(OnBannerLoadStatus)) + m.authorId = "" + + InitializeTabs() end function function OnNodeready() @@ -42,9 +49,28 @@ function OnContentSet() as void end if end if - m.rowList.content = content - content@.LoadChannel(m.invidious) + + authorId = ValidString(content.authorId) + if authorId <> m.authorId and IsArray(content.tabs) + m.authorId = authorId + m.rowList.contentData = CreateChannelFeeds(m.authorId, content.tabs) + end if +end function + +function CreateChannelFeeds(authorId as string, tabs as object) as object + if authorId = "" + return invalid + end if + + feeds = [] + for i = 0 to tabs.count() - 1 + tabName = tabs[i] + if m.tabs.DoesExist(tabName) + feeds.Push(m.tabs[tabName](authorId)) + end if + end for + return feeds end function function OnkeyEvent(key as string, press as boolean) as boolean @@ -71,4 +97,47 @@ function OnBannerLoadStatus() as void aspect = m.banner.bitmapWidth / m.banner.bitmapHeight m.banner.height = m.banner.width / aspect + m.banner.translation = [0, -m.banner.height] + m.banner.visible = true + + startPos = [0, 0] + endPos = [0, m.banner.height] + midPos = [0, m.banner.height / 2] + + m.scrollAnimationInterpolator.keyValue = [startPos, midPos, endPos] + m.scrollAnimation.control = "start" +end function + +function InitializeTabs() + m.tabs = { + videos: function(authorId as string) as object + return CreateChannelFeed("Latest videos", "channel_videos", authorId) + end function, + shorts: function(authorId as string) as object + return CreateChannelFeed("Shorts", "channel_shorts", authorId) + end function, + streams: function(authorId as string) as object + return CreateChannelFeed("Live", "channel_streams", authorId) + end function, + podcasts: function(authorId as string) as object + return CreateChannelFeed("Podcasts", "channel_podcasts", authorId) + end function, + playlists: function(authorId as string) as object + return CreateChannelFeed("Playlists", "channel_playlists", authorId) + end function, + channels: function(authorId as string) as object + return CreateChannelFeed("Channels", "channel_channels", authorId) + end function + } +end function + +function CreateChannelFeed(title as string, endpoint as string, ucid as string) as object + return { + title: title, + apiType: "Invidious", + endpoint: endpoint, + pathParams: { + ucid: ucid + } + } end function diff --git a/playlet-lib/src/components/ChannelView/ChannelView.xml b/playlet-lib/src/components/ChannelView/ChannelView.xml index f8b620d1..62c84169 100644 --- a/playlet-lib/src/components/ChannelView/ChannelView.xml +++ b/playlet-lib/src/components/ChannelView/ChannelView.xml @@ -11,44 +11,57 @@ color="0x242424"> -