From 12927edd6344869d5a07c72fb9f0767a27ceb385 Mon Sep 17 00:00:00 2001 From: WardPearce Date: Fri, 13 Feb 2026 15:55:04 +1300 Subject: [PATCH] Improved channel on YT backend --- materialious/src/lib/api/youtubejs/channel.ts | 16 +++++---- .../src/lib/components/Thumbnail.svelte | 4 ++- .../routes/(app)/channel/[slug]/+page.svelte | 35 +++++++++++++------ 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/materialious/src/lib/api/youtubejs/channel.ts b/materialious/src/lib/api/youtubejs/channel.ts index b0156378..fd77bc6a 100644 --- a/materialious/src/lib/api/youtubejs/channel.ts +++ b/materialious/src/lib/api/youtubejs/channel.ts @@ -18,10 +18,15 @@ export async function getChannelYTjs(channelId: string): Promise { const authorId = innerResults.metadata.url?.split('/')[4] ?? ''; let authorBanners: Image[] = []; - if (innerResults.header?.is(YTNodes.PageHeaderView)) { - authorBanners = innerResults.header.banner?.image ?? []; + if ( + innerResults.header?.is(YTNodes.PageHeader) && + innerResults.header.content?.is(YTNodes.PageHeaderView) + ) { + authorBanners = innerResults.header.content.banner?.image ?? []; } + const description = innerResults.metadata.description ?? ''; + return { type: 'channel', allowedRegions: innerResults.metadata.available_countries ?? [], @@ -38,8 +43,8 @@ export async function getChannelYTjs(channelId: string): Promise { authorUrl: `/channel/${authorId}`, subCount: 0, autoGenerated: false, - description: '', - descriptionHml: '' + description, + descriptionHml: description }; } @@ -91,7 +96,6 @@ function fetchChannelContentVideosWithContinuation( } async function fetchChannelContentWithContinuation( - channelId: string, innerResults: YT.Channel | YT.ChannelListContinuation, author: string ): Promise { @@ -131,5 +135,5 @@ export async function getChannelContentYTjs( innerResults = await channel.getLiveStreams(); } - return fetchChannelContentWithContinuation(channelId, innerResults, author); + return fetchChannelContentWithContinuation(innerResults, author); } diff --git a/materialious/src/lib/components/Thumbnail.svelte b/materialious/src/lib/components/Thumbnail.svelte index 25d0ee35..3968e65f 100644 --- a/materialious/src/lib/components/Thumbnail.svelte +++ b/materialious/src/lib/components/Thumbnail.svelte @@ -250,7 +250,9 @@
{video.viewCountText ?? cleanNumber(video.viewCount ?? 0)} • - {isYTBackend() ? relativeTimestamp(video.published, false) : video.publishedText} + {isYTBackend() && video.published !== 0 + ? relativeTimestamp(video.published, false) + : video.publishedText}
{/if} diff --git a/materialious/src/routes/(app)/channel/[slug]/+page.svelte b/materialious/src/routes/(app)/channel/[slug]/+page.svelte index 0a54dbb5..7ff220a7 100644 --- a/materialious/src/routes/(app)/channel/[slug]/+page.svelte +++ b/materialious/src/routes/(app)/channel/[slug]/+page.svelte @@ -36,31 +36,46 @@ async function loadMore(event: InfiniteEvent) { if (typeof displayContent === 'undefined') return; - if (typeof displayContent.continuation === 'undefined') { - event.detail.complete(); - return; + let completed = false; + let newContent: ChannelContent; + if (displayContent.getContinuation) { + newContent = await displayContent.getContinuation(); + displayContent.getContinuation = newContent.getContinuation; + + completed = newContent.getContinuation === undefined; + } else { + if (typeof displayContent.continuation === 'undefined') { + event.detail.complete(); + return; + } + + newContent = await getChannelContent(page.params.slug, { + type: tab, + continuation: displayContent.continuation, + sortBy: sortBy + }); + + completed = displayContent.continuation === newContent.continuation; } - const newContent = await getChannelContent(page.params.slug, { - type: tab, - continuation: displayContent.continuation, - sortBy: sortBy - }); if ('videos' in newContent && 'videos' in displayContent) { - if (displayContent.continuation === newContent.continuation) { + if (completed) { event.detail.complete(); } else { event.detail.loaded(); } + displayContent.videos = [...displayContent.videos, ...newContent.videos]; } else if ('playlists' in displayContent && 'playlists' in newContent) { - if (displayContent.continuation === newContent.continuation) { + if (completed) { event.detail.complete(); } else { event.detail.loaded(); } + displayContent.playlists = [...displayContent.playlists, ...newContent.playlists]; } + displayContent.continuation = newContent.continuation; }