feat: add VideoAttributeView (#531)

* feat: add `VideoAttributeView`

* fix: remove `logging_directives`

See https://github.com/LuanRT/YouTube.js/pull/531#discussion_r1375315550

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

---------

Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
Co-authored-by: Luan <luan.lrt4@gmail.com>
This commit is contained in:
JellyBrick
2023-12-01 09:38:51 +09:00
committed by GitHub
parent 9007b65237
commit ff4ab1680e
4 changed files with 49 additions and 4 deletions

View File

@@ -7,12 +7,13 @@ 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;
@@ -20,7 +21,7 @@ export default class EngagementPanelSectionList extends YTNode {
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;

View File

@@ -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);

View File

@@ -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;
}
}