Fixes to channel content ytjs

This commit is contained in:
WardPearce
2026-02-12 15:55:59 +13:00
parent 43e6eb78ed
commit 013b8ea289
+25 -5
View File
@@ -1,6 +1,13 @@
import { YT, YTNodes } from 'youtubei.js';
import { getInnertube } from '.';
import type { ChannelContent, ChannelOptions, ChannelPage, Image, Video } from '../model';
import type {
ChannelContent,
ChannelContentVideos,
ChannelOptions,
ChannelPage,
Image,
Video
} from '../model';
import { invidiousItemSchema } from './schema';
export async function getChannelYTjs(channelId: string): Promise<ChannelPage> {
@@ -70,6 +77,19 @@ export function invidiousChannelContentSchema(
return videos;
}
function fetchChannelContentVideosWithContinuation(
innerResults: YT.ChannelListContinuation,
author: string
): () => Promise<ChannelContentVideos> {
return async () => {
const continuation = await innerResults.getContinuation();
return {
videos: invidiousChannelContentSchema(continuation, author),
getContinuation: fetchChannelContentVideosWithContinuation(continuation, author)
};
};
}
async function fetchChannelContentWithContinuation(
channelId: string,
innerResults: YT.Channel | YT.ChannelListContinuation,
@@ -81,10 +101,10 @@ async function fetchChannelContentWithContinuation(
};
if (channelContent.continuation) {
channelContent.getContinuation = async () => {
const continuation = await innerResults.getContinuation();
return fetchChannelContentWithContinuation(channelId, continuation, author);
};
channelContent.getContinuation = fetchChannelContentVideosWithContinuation(
innerResults,
author
);
}
return channelContent;