Improved channel on YT backend
This commit is contained in:
@@ -18,10 +18,15 @@ export async function getChannelYTjs(channelId: string): Promise<ChannelPage> {
|
||||
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<ChannelPage> {
|
||||
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<ChannelContent> {
|
||||
@@ -131,5 +135,5 @@ export async function getChannelContentYTjs(
|
||||
innerResults = await channel.getLiveStreams();
|
||||
}
|
||||
|
||||
return fetchChannelContentWithContinuation(channelId, innerResults, author);
|
||||
return fetchChannelContentWithContinuation(innerResults, author);
|
||||
}
|
||||
|
||||
@@ -250,7 +250,9 @@
|
||||
<div class="max">
|
||||
{video.viewCountText ?? cleanNumber(video.viewCount ?? 0)}
|
||||
•
|
||||
{isYTBackend() ? relativeTimestamp(video.published, false) : video.publishedText}
|
||||
{isYTBackend() && video.published !== 0
|
||||
? relativeTimestamp(video.published, false)
|
||||
: video.publishedText}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user