Set channel id for channel content

This commit is contained in:
WardPearce
2026-03-08 15:32:49 +13:00
parent 46e21cf5ee
commit 0a0f513478
2 changed files with 16 additions and 12 deletions
+15 -12
View File
@@ -16,8 +16,6 @@ export async function getChannelYTjs(channelId: string): Promise<ChannelPage> {
const innerResults = await innertube.getChannel(channelId);
const authorId = innerResults.metadata.url?.split('/')[4] ?? '';
let authorBanners: Image[] = [];
if (
innerResults.header?.is(YTNodes.PageHeader) &&
@@ -38,12 +36,12 @@ export async function getChannelYTjs(channelId: string): Promise<ChannelPage> {
isFamilyFriendly: true,
author: innerResults.metadata.title ?? '',
authorThumbnails: innerResults.metadata.avatar ?? [],
authorId: authorId,
authorId: channelId,
authorBanners,
joined: 0,
authorVerified: true,
totalViews: 0,
authorUrl: `/channel/${authorId}`,
authorUrl: `/channel/${channelId}`,
subCount: 0,
autoGenerated: false,
description,
@@ -53,7 +51,8 @@ export async function getChannelYTjs(channelId: string): Promise<ChannelPage> {
export function invidiousChannelContentSchema(
innerResults: YT.Channel | YT.ChannelListContinuation,
author: string
author: string,
authorId: string
) {
const videos: Video[] = [];
@@ -77,6 +76,7 @@ export function invidiousChannelContentSchema(
const invidiousSchema = invidiousItemSchema(item.content);
if (invidiousSchema?.type === 'video') {
invidiousSchema.author = author;
invidiousSchema.authorId = authorId;
videos.push(invidiousSchema);
}
}
@@ -87,30 +87,33 @@ export function invidiousChannelContentSchema(
function fetchChannelContentVideosWithContinuation(
innerResults: YT.ChannelListContinuation,
author: string
author: string,
authorId: string
): () => Promise<ChannelContentVideos> {
return async () => {
const continuation = await innerResults.getContinuation();
return {
videos: invidiousChannelContentSchema(continuation, author),
getContinuation: fetchChannelContentVideosWithContinuation(continuation, author)
videos: invidiousChannelContentSchema(continuation, author, authorId),
getContinuation: fetchChannelContentVideosWithContinuation(continuation, author, authorId)
};
};
}
async function fetchChannelContentWithContinuation(
innerResults: YT.Channel | YT.ChannelListContinuation,
author: string
author: string,
authorId: string
): Promise<ChannelContent> {
const channelContent: ChannelContent = {
continuation: innerResults.has_continuation ? 'logicalPlaceholder' : undefined,
videos: invidiousChannelContentSchema(innerResults, author)
videos: invidiousChannelContentSchema(innerResults, author, authorId)
};
if (channelContent.continuation) {
channelContent.getContinuation = fetchChannelContentVideosWithContinuation(
innerResults,
author
author,
authorId
);
}
@@ -138,5 +141,5 @@ export async function getChannelContentYTjs(
innerResults = await channel.getLiveStreams();
}
return fetchChannelContentWithContinuation(innerResults, author);
return fetchChannelContentWithContinuation(innerResults, author, channelId);
}
@@ -6,6 +6,7 @@ import { Helpers, YTNodes } from 'youtubei.js';
export function invidiousItemSchema(item: Helpers.YTNode): Video | Channel | Playlist | undefined {
if (item.is(YTNodes.Video)) {
const views = extractNumber(item.view_count?.toString() || '');
console.log(item);
return {
type: 'video',
title: item.title.toString(),