mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 04:21:35 +00:00
feat: add support for YouTube Kids (#291)
* dev: add `WEB_KIDS` innertube client * refactor: move DASH manifest stuff out of `VideoInfo` This makes it easier to use these functions elsewhere. * feat(ytkids): add `Kids#getInfo()` & `Kids#search()` * feat: add `Innertube#kids.getHomeFeed()` * docs: add YouTube Kids API ref * docs: fix typo * docs: fix yet another typo * docs: update YouTube Music API ref Unrelated but required to reflect changes made to the DASH manifest generation functions * chore: lint * chore: add tests * feat: include `captions` in `VideoInfo` * chore: fix tests
This commit is contained in:
35
src/parser/classes/CompactChannel.ts
Normal file
35
src/parser/classes/CompactChannel.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import Parser from '..';
|
||||
import Text from './misc/Text';
|
||||
import Thumbnail from './misc/Thumbnail';
|
||||
import NavigationEndpoint from './NavigationEndpoint';
|
||||
import type Menu from './menus/Menu';
|
||||
import { YTNode } from '../helpers';
|
||||
|
||||
class CompactChannel extends YTNode {
|
||||
static type = 'CompactChannel';
|
||||
|
||||
title: Text;
|
||||
channel_id: string;
|
||||
thumbnail: Thumbnail[];
|
||||
display_name: Text;
|
||||
video_count: Text;
|
||||
subscriber_count: Text;
|
||||
endpoint: NavigationEndpoint;
|
||||
tv_banner: Thumbnail[];
|
||||
menu: Menu | null;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.title = new Text(data.title);
|
||||
this.channel_id = data.channelId;
|
||||
this.thumbnail = Thumbnail.fromResponse(data.thumbnail);
|
||||
this.display_name = new Text(data.displayName);
|
||||
this.video_count = new Text(data.videoCountText);
|
||||
this.subscriber_count = new Text(data.subscriberCountText);
|
||||
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
|
||||
this.tv_banner = Thumbnail.fromResponse(data.tvBanner);
|
||||
this.menu = Parser.parseItem<Menu>(data.menu);
|
||||
}
|
||||
}
|
||||
|
||||
export default CompactChannel;
|
||||
25
src/parser/classes/SlimOwner.ts
Normal file
25
src/parser/classes/SlimOwner.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import Parser from '..';
|
||||
import Text from './misc/Text';
|
||||
import Thumbnail from './misc/Thumbnail';
|
||||
import NavigationEndpoint from './NavigationEndpoint';
|
||||
import SubscribeButton from './SubscribeButton';
|
||||
import { YTNode } from '../helpers';
|
||||
|
||||
class SlimOwner extends YTNode {
|
||||
static type = 'SlimOwner';
|
||||
|
||||
thumbnail: Thumbnail[];
|
||||
title: Text;
|
||||
endpoint: NavigationEndpoint;
|
||||
subscribe_button: SubscribeButton | null;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.thumbnail = Thumbnail.fromResponse(data.thumbnail);
|
||||
this.title = new Text(data.title);
|
||||
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
|
||||
this.subscribe_button = Parser.parseItem<SubscribeButton>(data.subscribeButton, SubscribeButton);
|
||||
}
|
||||
}
|
||||
|
||||
export default SlimOwner;
|
||||
28
src/parser/classes/SlimVideoMetadata.ts
Normal file
28
src/parser/classes/SlimVideoMetadata.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import Parser from '..';
|
||||
import Text from './misc/Text';
|
||||
import { YTNode } from '../helpers';
|
||||
|
||||
class SlimVideoMetadata extends YTNode {
|
||||
static type = 'SlimVideoMetadata';
|
||||
|
||||
title: Text;
|
||||
collapsed_subtitle: Text;
|
||||
expanded_subtitle: Text;
|
||||
owner: any;
|
||||
description: Text;
|
||||
video_id: string;
|
||||
date: Text;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.title = new Text(data.title);
|
||||
this.collapsed_subtitle = new Text(data.collapsedSubtitle);
|
||||
this.expanded_subtitle = new Text(data.expandedSubtitle);
|
||||
this.owner = Parser.parseItem(data.owner);
|
||||
this.description = new Text(data.description);
|
||||
this.video_id = data.videoId;
|
||||
this.date = new Text(data.dateText);
|
||||
}
|
||||
}
|
||||
|
||||
export default SlimVideoMetadata;
|
||||
31
src/parser/classes/ytkids/AnchoredSection.ts
Normal file
31
src/parser/classes/ytkids/AnchoredSection.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import Parser from '../..';
|
||||
import NavigationEndpoint from '../NavigationEndpoint';
|
||||
import type SectionList from '../SectionList';
|
||||
import { YTNode } from '../../helpers';
|
||||
|
||||
class AnchoredSection extends YTNode {
|
||||
static type = 'AnchoredSection';
|
||||
|
||||
title: string;
|
||||
content: SectionList | null;
|
||||
endpoint: NavigationEndpoint;
|
||||
category_assets: {
|
||||
asset_key: string;
|
||||
background_color: string;
|
||||
};
|
||||
category_type: string;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.title = data.title;
|
||||
this.content = Parser.parseItem<SectionList>(data.content);
|
||||
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
|
||||
this.category_assets = {
|
||||
asset_key: data.categoryAssets?.assetKey,
|
||||
background_color: data.categoryAssets?.backgroundColor
|
||||
};
|
||||
this.category_type = data.categoryType;
|
||||
}
|
||||
}
|
||||
|
||||
export default AnchoredSection;
|
||||
19
src/parser/classes/ytkids/KidsCategoriesHeader.ts
Normal file
19
src/parser/classes/ytkids/KidsCategoriesHeader.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import Parser from '../..';
|
||||
import type Button from '../Button';
|
||||
import type KidsCategoryTab from './KidsCategoryTab';
|
||||
import { YTNode } from '../../helpers';
|
||||
|
||||
class KidsCategoriesHeader extends YTNode {
|
||||
static type = 'kidsCategoriesHeader';
|
||||
|
||||
category_tabs: KidsCategoryTab[];
|
||||
privacy_button: Button | null;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.category_tabs = Parser.parseArray<KidsCategoryTab>(data.categoryTabs);
|
||||
this.privacy_button = Parser.parseItem<Button>(data.privacyButtonRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
export default KidsCategoriesHeader;
|
||||
28
src/parser/classes/ytkids/KidsCategoryTab.ts
Normal file
28
src/parser/classes/ytkids/KidsCategoryTab.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import Text from '../misc/Text';
|
||||
import NavigationEndpoint from '../NavigationEndpoint';
|
||||
import { YTNode } from '../../helpers';
|
||||
|
||||
class KidsCategoryTab extends YTNode {
|
||||
static type = 'KidsCategoryTab';
|
||||
|
||||
title: Text;
|
||||
category_assets: {
|
||||
asset_key: string;
|
||||
background_color: string;
|
||||
};
|
||||
category_type: string;
|
||||
endpoint: NavigationEndpoint;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.title = new Text(data.title);
|
||||
this.category_assets = {
|
||||
asset_key: data.categoryAssets?.assetKey,
|
||||
background_color: data.categoryAssets?.backgroundColor
|
||||
};
|
||||
this.category_type = data.categoryType;
|
||||
this.endpoint = new NavigationEndpoint(data.endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
export default KidsCategoryTab;
|
||||
16
src/parser/classes/ytkids/KidsHomeScreen.ts
Normal file
16
src/parser/classes/ytkids/KidsHomeScreen.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import Parser from '../..';
|
||||
import type AnchoredSection from './AnchoredSection';
|
||||
import { YTNode } from '../../helpers';
|
||||
|
||||
class KidsHomeScreen extends YTNode {
|
||||
static type = 'kidsHomeScreen';
|
||||
|
||||
anchors;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.anchors = Parser.parseArray<AnchoredSection>(data.anchors);
|
||||
}
|
||||
}
|
||||
|
||||
export default KidsHomeScreen;
|
||||
Reference in New Issue
Block a user