Files
YouTube.js/src/parser/classes/analytics/AnalyticsRoot.ts
Chinmay Kumar cfc1a183e0 refactor(parser): type YTNodes' data arg as RawNode (wip) (#339)
* replaced YTNode's data arg as RawNode

* updated documentation

* removed unused import

---- Note that there are still many nodes that need to be updated, hence the WIP status.
2023-03-07 02:02:07 -03:00

46 lines
1.2 KiB
TypeScript

import { YTNode } from '../../helpers.js';
import type { RawNode } from '../../index.js';
class AnalyticsRoot extends YTNode {
static type = 'AnalyticsRoot';
title: string;
selected_card_index_key: string;
use_main_app_specs: boolean;
table_cards: {
title: string;
rows: {
label: string;
display_value: string;
display_value_a11y: string;
bar_ratio: number;
bar_color: number;
bar_opacity: number;
}[];
}[];
constructor(data: RawNode) {
super();
const cards = data.analyticsTableCarouselData.data.tableCards;
this.title = data.analyticsTableCarouselData.carouselTitle;
this.selected_card_index_key = data.analyticsTableCarouselData.selectedCardIndexKey;
this.table_cards = cards.map((card: any) => ({
title: card.cardData.title,
rows: card.cardData.rows.map((row: any) => ({
label: row.label,
display_value: row.displayValue,
display_value_a11y: row.displayValueA11y,
bar_ratio: row.barRatio,
bar_color: row.barColor,
bar_opacity: row.barOpacity
}))
}));
this.use_main_app_specs = data.analyticsTableCarouselData.useMainAppSpecs;
}
}
export default AnalyticsRoot;