mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-23 14:38:07 +00:00
feat(ytmusic): add taste builder nodes (#383)
Adds MusicTastebuilderShelf and MusicTastebuilderShelfThumbnail. These usually appear on new accounts.
This commit is contained in:
26
src/parser/classes/MusicTastebuilderShelf.ts
Normal file
26
src/parser/classes/MusicTastebuilderShelf.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import Parser from '../index.js';
|
||||
import Button from './Button.js';
|
||||
import Text from './misc/Text.js';
|
||||
import MusicTastebuilderShelfThumbnail from './MusicTastebuilderShelfThumbnail.js';
|
||||
|
||||
import { YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
|
||||
export default class MusicTasteBuilderShelf extends YTNode {
|
||||
static type = 'MusicTasteBuilderShelf';
|
||||
|
||||
thumbnail: MusicTastebuilderShelfThumbnail | null;
|
||||
primary_text: Text;
|
||||
secondary_text: Text;
|
||||
action_button: Button | null;
|
||||
is_visible: boolean;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.thumbnail = Parser.parseItem(data.thumbnail, MusicTastebuilderShelfThumbnail);
|
||||
this.primary_text = new Text(data.primaryText);
|
||||
this.secondary_text = new Text(data.secondaryText);
|
||||
this.action_button = Parser.parseItem(data.actionButton, Button);
|
||||
this.is_visible = data.isVisible;
|
||||
}
|
||||
}
|
||||
14
src/parser/classes/MusicTastebuilderShelfThumbnail.ts
Normal file
14
src/parser/classes/MusicTastebuilderShelfThumbnail.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { Thumbnail } from '../misc.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
|
||||
export default class MusicTastebuilderShelfThumbnail extends YTNode {
|
||||
static type = 'MusicTastebuilderShelfThumbnail';
|
||||
|
||||
thumbnail: Thumbnail[];
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.thumbnail = Thumbnail.fromResponse(data.thumbnail);
|
||||
}
|
||||
}
|
||||
@@ -219,6 +219,8 @@ export { default as MusicResponsiveListItemFlexColumn } from './classes/MusicRes
|
||||
export { default as MusicShelf } from './classes/MusicShelf.js';
|
||||
export { default as MusicSideAlignedItem } from './classes/MusicSideAlignedItem.js';
|
||||
export { default as MusicSortFilterButton } from './classes/MusicSortFilterButton.js';
|
||||
export { default as MusicTastebuilderShelf } from './classes/MusicTastebuilderShelf.js';
|
||||
export { default as MusicTastebuilderShelfThumbnail } from './classes/MusicTastebuilderShelfThumbnail.js';
|
||||
export { default as MusicThumbnail } from './classes/MusicThumbnail.js';
|
||||
export { default as MusicTwoRowItem } from './classes/MusicTwoRowItem.js';
|
||||
export { default as MusicVisualHeader } from './classes/MusicVisualHeader.js';
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import Parser, { SectionListContinuation } from '../index.js';
|
||||
import MusicCarouselShelf from '../classes/MusicCarouselShelf.js';
|
||||
import SectionList from '../classes/SectionList.js';
|
||||
import SingleColumnBrowseResults from '../classes/SingleColumnBrowseResults.js';
|
||||
import Parser, { SectionListContinuation } from '../index.js';
|
||||
import MusicTastebuilderShelf from '../classes/MusicTastebuilderShelf.js';
|
||||
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { ObservedArray } from '../helpers.js';
|
||||
import type { IBrowseResponse } from '../types/ParsedResponse.js';
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
|
||||
class HomeFeed {
|
||||
#page: IBrowseResponse;
|
||||
#actions: Actions;
|
||||
#continuation?: string;
|
||||
|
||||
sections?: ObservedArray<MusicCarouselShelf>;
|
||||
sections?: ObservedArray<MusicCarouselShelf | MusicTastebuilderShelf>;
|
||||
|
||||
constructor(response: ApiResponse, actions: Actions) {
|
||||
this.#actions = actions;
|
||||
@@ -36,7 +37,7 @@ class HomeFeed {
|
||||
}
|
||||
|
||||
this.#continuation = tab.content?.as(SectionList).continuation;
|
||||
this.sections = tab.content?.as(SectionList).contents.as(MusicCarouselShelf);
|
||||
this.sections = tab.content?.as(SectionList).contents.as(MusicCarouselShelf, MusicTastebuilderShelf);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user