mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-26 08:08:54 +00:00
feat(yt): add getGuide() (#335)
* feat(yt): add `getGuide()` * chore: lint * fix(Guide): wrong prop * fix(Guide): include subscription section * fix(Guide): wrong import * feat(Guide): add `page`
This commit is contained in:
35
src/parser/classes/GuideCollapsibleEntry.ts
Normal file
35
src/parser/classes/GuideCollapsibleEntry.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import Text from './misc/Text.js';
|
||||
import { YTNode } from '../helpers.js';
|
||||
import Parser from '../parser.js';
|
||||
|
||||
class GuideCollapsibleEntry extends YTNode {
|
||||
static type = 'GuideCollapsibleEntry';
|
||||
|
||||
expander_item: {
|
||||
title: string,
|
||||
icon_type: string
|
||||
};
|
||||
collapser_item: {
|
||||
title: string,
|
||||
icon_type: string
|
||||
};
|
||||
expandable_items;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
|
||||
this.expander_item = {
|
||||
title: new Text(data.expanderItem.guideEntryRenderer.formattedTitle).toString(),
|
||||
icon_type: data.expanderItem.guideEntryRenderer.icon.iconType
|
||||
};
|
||||
|
||||
this.collapser_item = {
|
||||
title: new Text(data.collapserItem.guideEntryRenderer.formattedTitle).toString(),
|
||||
icon_type: data.collapserItem.guideEntryRenderer.icon.iconType
|
||||
};
|
||||
|
||||
this.expandable_items = Parser.parseArray(data.expandableItems);
|
||||
}
|
||||
}
|
||||
|
||||
export default GuideCollapsibleEntry;
|
||||
23
src/parser/classes/GuideCollapsibleSectionEntry.ts
Normal file
23
src/parser/classes/GuideCollapsibleSectionEntry.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import Parser from '../parser.js';
|
||||
|
||||
class GuideCollapsibleSectionEntry extends YTNode {
|
||||
static type = 'GuideCollapsibleSectionEntry';
|
||||
|
||||
header_entry;
|
||||
expander_icon: string;
|
||||
collapser_icon: string;
|
||||
section_items;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
|
||||
this.header_entry = Parser.parseItem(data.headerEntry);
|
||||
this.expander_icon = data.expanderIcon.iconType;
|
||||
this.collapser_icon = data.collapserIcon.iconType;
|
||||
this.section_items = Parser.parseArray(data.sectionItems);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export default GuideCollapsibleSectionEntry;
|
||||
14
src/parser/classes/GuideDownloadsEntry.ts
Normal file
14
src/parser/classes/GuideDownloadsEntry.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import GuideEntry from './GuideEntry.js';
|
||||
|
||||
class GuideDownloadsEntry extends GuideEntry {
|
||||
static type = 'GuideDownloadsEntry';
|
||||
|
||||
always_show: boolean;
|
||||
|
||||
constructor(data: any) {
|
||||
super(data.entryRenderer.guideEntryRenderer);
|
||||
this.always_show = !!data.alwaysShow;
|
||||
}
|
||||
}
|
||||
|
||||
export default GuideDownloadsEntry;
|
||||
33
src/parser/classes/GuideEntry.ts
Normal file
33
src/parser/classes/GuideEntry.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import Text from './misc/Text.js';
|
||||
import NavigationEndpoint from './NavigationEndpoint.js';
|
||||
import { YTNode } from '../helpers.js';
|
||||
import Thumbnail from './misc/Thumbnail.js';
|
||||
|
||||
class GuideEntry extends YTNode {
|
||||
static type = 'GuideEntry';
|
||||
|
||||
title: Text;
|
||||
endpoint: NavigationEndpoint;
|
||||
icon_type?: string;
|
||||
thumbnails?: Thumbnail[];
|
||||
badges?: any;
|
||||
is_primary: boolean;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.title = new Text(data.formattedTitle);
|
||||
this.endpoint = new NavigationEndpoint(data.navigationEndpoint || data.serviceEndpoint);
|
||||
if (data.icon?.iconType) {
|
||||
this.icon_type = data.icon.iconType;
|
||||
}
|
||||
if (data.thumbnail) {
|
||||
this.thumbnails = Thumbnail.fromResponse(data.thumbnail);
|
||||
}
|
||||
if (data.badges) {
|
||||
this.badges = data.badges;
|
||||
}
|
||||
this.is_primary = !!data.isPrimary;
|
||||
}
|
||||
}
|
||||
|
||||
export default GuideEntry;
|
||||
20
src/parser/classes/GuideSection.ts
Normal file
20
src/parser/classes/GuideSection.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import Text from './misc/Text.js';
|
||||
import { YTNode } from '../helpers.js';
|
||||
import Parser from '../parser.js';
|
||||
|
||||
class GuideSection extends YTNode {
|
||||
static type = 'GuideSection';
|
||||
|
||||
title?: Text;
|
||||
items;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
if (data.formattedTitle) {
|
||||
this.title = new Text(data.formattedTitle);
|
||||
}
|
||||
this.items = Parser.parseArray(data.items);
|
||||
}
|
||||
}
|
||||
|
||||
export default GuideSection;
|
||||
7
src/parser/classes/GuideSubscriptionsSection.ts
Normal file
7
src/parser/classes/GuideSubscriptionsSection.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import GuideSection from './GuideSection.js';
|
||||
|
||||
class GuideSubscriptionsSection extends GuideSection {
|
||||
static type = 'GuideSubscriptionsSection';
|
||||
}
|
||||
|
||||
export default GuideSubscriptionsSection;
|
||||
Reference in New Issue
Block a user