Skip to content

Commit

Permalink
feat: add VideoMetadataCarouselView (#839)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonz94 authored Dec 12, 2024
1 parent 0b2b0da commit 9a9bb76
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/parser/classes/CarouselItemView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { YTNode } from '../helpers.js';
import { Parser, type RawNode } from '../index.js';
import TextCarouselItemView from './TextCarouselItemView.js';

export default class CarouselItemView extends YTNode {
static type = 'CarouselItemView';

item_type: string;
carousel_item: TextCarouselItemView | null;

constructor(data: RawNode) {
super();
this.item_type = data.itemType;
this.carousel_item = Parser.parseItem(data.carouselItem, TextCarouselItemView);
}
}
18 changes: 18 additions & 0 deletions src/parser/classes/CarouselTitleView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { YTNode } from '../helpers.js';
import { Parser, type RawNode } from '../index.js';
import ButtonView from './ButtonView.js';

export default class CarouselTitleView extends YTNode {
static type = 'CarouselTitleView';

title: string;
previous_button: ButtonView | null;
next_button: ButtonView | null;

constructor(data: RawNode) {
super();
this.title = data.title;
this.previous_button = Parser.parseItem(data.previousButton, ButtonView);
this.next_button = Parser.parseItem(data.nextButton, ButtonView);
}
}
22 changes: 22 additions & 0 deletions src/parser/classes/TextCarouselItemView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { YTNode } from '../helpers.js';
import { Parser, type RawNode } from '../index.js';
import { Text } from '../misc.js';
import ButtonView from './ButtonView.js';
import NavigationEndpoint from './NavigationEndpoint.js';

export default class TextCarouselItemView extends YTNode {
static type = 'TextCarouselItemView';

icon_name: string;
text: Text;
on_tap_endpoint: NavigationEndpoint;
button: ButtonView | null;

constructor(data: RawNode) {
super();
this.icon_name = data.iconName;
this.text = Text.fromAttributed(data.text);
this.on_tap_endpoint = new NavigationEndpoint(data.onTap);
this.button = Parser.parseItem(data.button, ButtonView);
}
}
17 changes: 17 additions & 0 deletions src/parser/classes/VideoMetadataCarouselView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import { Parser, type RawNode } from '../index.js';
import CarouselItemView from './CarouselItemView.js';
import CarouselTitleView from './CarouselTitleView.js';

export default class VideoMetadataCarouselView extends YTNode {
static type = 'VideoMetadataCarouselView';

carousel_titles: ObservedArray<CarouselTitleView> | null;
carousel_items: ObservedArray<CarouselItemView> | null;

constructor(data: RawNode) {
super();
this.carousel_titles = Parser.parse(data.carouselTitles, true, CarouselTitleView);
this.carousel_items = Parser.parse(data.carouselItems, true, CarouselItemView);
}
}
4 changes: 4 additions & 0 deletions src/parser/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export { default as Card } from './classes/Card.js';
export { default as CardCollection } from './classes/CardCollection.js';
export { default as CarouselHeader } from './classes/CarouselHeader.js';
export { default as CarouselItem } from './classes/CarouselItem.js';
export { default as CarouselItemView } from './classes/CarouselItemView.js';
export { default as CarouselLockup } from './classes/CarouselLockup.js';
export { default as CarouselTitleView } from './classes/CarouselTitleView.js';
export { default as Channel } from './classes/Channel.js';
export { default as ChannelAboutFullMetadata } from './classes/ChannelAboutFullMetadata.js';
export { default as ChannelAgeGate } from './classes/ChannelAgeGate.js';
Expand Down Expand Up @@ -441,6 +443,7 @@ export { default as SubscriptionNotificationToggleButton } from './classes/Subsc
export { default as Tab } from './classes/Tab.js';
export { default as Tabbed } from './classes/Tabbed.js';
export { default as TabbedSearchResults } from './classes/TabbedSearchResults.js';
export { default as TextCarouselItemView } from './classes/TextCarouselItemView.js';
export { default as TextFieldView } from './classes/TextFieldView.js';
export { default as TextHeader } from './classes/TextHeader.js';
export { default as ThirdPartyShareTargetSection } from './classes/ThirdPartyShareTargetSection.js';
Expand Down Expand Up @@ -494,6 +497,7 @@ export { default as VideoDescriptionInfocardsSection } from './classes/VideoDesc
export { default as VideoDescriptionMusicSection } from './classes/VideoDescriptionMusicSection.js';
export { default as VideoDescriptionTranscriptSection } from './classes/VideoDescriptionTranscriptSection.js';
export { default as VideoInfoCardContent } from './classes/VideoInfoCardContent.js';
export { default as VideoMetadataCarouselView } from './classes/VideoMetadataCarouselView.js';
export { default as VideoOwner } from './classes/VideoOwner.js';
export { default as VideoPrimaryInfo } from './classes/VideoPrimaryInfo.js';
export { default as VideoSecondaryInfo } from './classes/VideoSecondaryInfo.js';
Expand Down

0 comments on commit 9a9bb76

Please sign in to comment.