Skip to content

Commit

Permalink
feat: add VideoAttributeView (#531)
Browse files Browse the repository at this point in the history
* feat: add `VideoAttributeView`

* fix: remove `logging_directives`

See #531 (comment)

* fix: Update src/parser/classes/VideoAttributeView.ts

---------

Co-authored-by: absidue <[email protected]>
Co-authored-by: Luan <[email protected]>
  • Loading branch information
3 people authored Dec 1, 2023
1 parent 9007b65 commit ff4ab16
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/parser/classes/EngagementPanelSectionList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ import MacroMarkersList from './MacroMarkersList.js';
import ProductList from './ProductList.js';
import SectionList from './SectionList.js';
import StructuredDescriptionContent from './StructuredDescriptionContent.js';
import VideoAttributeView from './VideoAttributeView.js';

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

header: EngagementPanelTitleHeader | null;
content: SectionList | ContinuationItem | ClipSection | StructuredDescriptionContent | MacroMarkersList | ProductList | null;
content: VideoAttributeView | SectionList | ContinuationItem | ClipSection | StructuredDescriptionContent | MacroMarkersList | ProductList | null;
target_id?: string;
panel_identifier?: string;
visibility?: string;

constructor(data: RawNode) {
super();
this.header = Parser.parseItem(data.header, EngagementPanelTitleHeader);
this.content = Parser.parseItem(data.content, [ SectionList, ContinuationItem, ClipSection, StructuredDescriptionContent, MacroMarkersList, ProductList ]);
this.content = Parser.parseItem(data.content, [ VideoAttributeView, SectionList, ContinuationItem, ClipSection, StructuredDescriptionContent, MacroMarkersList, ProductList ]);
this.panel_identifier = data.panelIdentifier;
this.target_id = data.targetId;
this.visibility = data.visibility;
Expand Down
5 changes: 3 additions & 2 deletions src/parser/classes/HorizontalCardList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ import Button from './Button.js';
import MacroMarkersListItem from './MacroMarkersListItem.js';
import GameCard from './GameCard.js';
import VideoCard from './VideoCard.js';
import VideoAttributeView from './VideoAttributeView.js';

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

cards: ObservedArray<SearchRefinementCard | MacroMarkersListItem | GameCard | VideoCard>;
cards: ObservedArray<VideoAttributeView | SearchRefinementCard | MacroMarkersListItem | GameCard | VideoCard>;
header: YTNode;
previous_button: Button | null;
next_button: Button | null;

constructor(data: RawNode) {
super();
this.cards = Parser.parseArray(data.cards, [ SearchRefinementCard, MacroMarkersListItem, GameCard, VideoCard ]);
this.cards = Parser.parseArray(data.cards, [ VideoAttributeView, SearchRefinementCard, MacroMarkersListItem, GameCard, VideoCard ]);
this.header = Parser.parseItem(data.header);
this.previous_button = Parser.parseItem(data.previousButton, Button);
this.next_button = Parser.parseItem(data.nextButton, Button);
Expand Down
42 changes: 42 additions & 0 deletions src/parser/classes/VideoAttributeView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { YTNode } from '../helpers.js';
import NavigationEndpoint from './NavigationEndpoint.js';

import ContentPreviewImageView from './ContentPreviewImageView.js';
import { Parser } from '../index.js';

import type { RawNode } from '../types/index.js';

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

image: ContentPreviewImageView | null;
image_style: string;
title: string;
subtitle: string;
secondary_subtitle: {
content: string
};
orientation: string;
sizing_rule: string;
overflow_menu_on_tap: {
innertube_command: NavigationEndpoint
};
overflow_menu_a11y_label: string;

constructor(data: RawNode) {
super();
this.image = Parser.parseItem(data.image, ContentPreviewImageView);
this.image_style = data.imageStyle;
this.title = data.title;
this.subtitle = data.subtitle;
this.secondary_subtitle = {
content: data.secondarySubtitle.content
};
this.orientation = data.orientation;
this.sizing_rule = data.sizingRule;
this.overflow_menu_on_tap = {
innertube_command: new NavigationEndpoint(data.overflowMenuOnTap.innertubeCommand)
};
this.overflow_menu_a11y_label = data.overflowMenuA11yLabel;
}
}
1 change: 1 addition & 0 deletions src/parser/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ export { default as UpsellDialog } from './classes/UpsellDialog.js';
export { default as VerticalList } from './classes/VerticalList.js';
export { default as VerticalWatchCardList } from './classes/VerticalWatchCardList.js';
export { default as Video } from './classes/Video.js';
export { default as VideoAttributeView } from './classes/VideoAttributeView.js';
export { default as VideoCard } from './classes/VideoCard.js';
export { default as VideoDescriptionCourseSection } from './classes/VideoDescriptionCourseSection.js';
export { default as VideoDescriptionHeader } from './classes/VideoDescriptionHeader.js';
Expand Down

0 comments on commit ff4ab16

Please sign in to comment.