mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-28 00:56:23 +00:00
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.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import DataModelSection from './DataModelSection.js';
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
class AnalyticsMainAppKeyMetrics extends YTNode {
|
||||
static type = 'AnalyticsMainAppKeyMetrics';
|
||||
@@ -7,7 +8,7 @@ class AnalyticsMainAppKeyMetrics extends YTNode {
|
||||
period: string;
|
||||
sections: DataModelSection[];
|
||||
|
||||
constructor(data: any) {
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.period = data.cardData.periodLabel;
|
||||
const metrics_data = data.cardData.sections[0].analyticsKeyMetricsData;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
class AnalyticsRoot extends YTNode {
|
||||
static type = 'AnalyticsRoot';
|
||||
@@ -19,7 +20,7 @@ class AnalyticsRoot extends YTNode {
|
||||
}[];
|
||||
}[];
|
||||
|
||||
constructor(data: any) {
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
const cards = data.analyticsTableCarouselData.data.tableCards;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
import NavigationEndpoint from '../NavigationEndpoint.js';
|
||||
|
||||
class AnalyticsShortsCarouselCard extends YTNode {
|
||||
@@ -11,7 +12,7 @@ class AnalyticsShortsCarouselCard extends YTNode {
|
||||
endpoint: NavigationEndpoint;
|
||||
}[];
|
||||
|
||||
constructor(data: any) {
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = data.title;
|
||||
this.shorts = data.shortsCarouselData.shorts.map((short: any) => ({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Thumbnail from '../misc/Thumbnail.js';
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
class AnalyticsVideo extends YTNode {
|
||||
static type = 'AnalyticsVideo';
|
||||
@@ -13,7 +14,7 @@ class AnalyticsVideo extends YTNode {
|
||||
is_short: boolean;
|
||||
};
|
||||
|
||||
constructor(data: any) {
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = data.videoTitle;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Video from './AnalyticsVideo.js';
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
class AnalyticsVodCarouselCard extends YTNode {
|
||||
static type = 'AnalyticsVodCarouselCard';
|
||||
@@ -8,7 +9,7 @@ class AnalyticsVodCarouselCard extends YTNode {
|
||||
videos: Video[] | null;
|
||||
no_data_message?: string;
|
||||
|
||||
constructor(data: any) {
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = data.title;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
class CtaGoToCreatorStudio extends YTNode {
|
||||
static type = 'CtaGoToCreatorStudio';
|
||||
@@ -6,7 +7,7 @@ class CtaGoToCreatorStudio extends YTNode {
|
||||
title: string;
|
||||
use_new_specs: boolean;
|
||||
|
||||
constructor(data: any) {
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = data.buttonLabel;
|
||||
this.use_new_specs = data.useNewSpecs;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
class DataModelSection extends YTNode {
|
||||
static type = 'DataModelSection';
|
||||
@@ -36,7 +37,7 @@ class DataModelSection extends YTNode {
|
||||
}
|
||||
};
|
||||
|
||||
constructor(data: any) {
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.title = data.title;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Text from '../misc/Text.js';
|
||||
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
class StatRow extends YTNode {
|
||||
static type = 'StatRow';
|
||||
@@ -8,7 +9,7 @@ class StatRow extends YTNode {
|
||||
title: Text;
|
||||
contents: Text;
|
||||
|
||||
constructor(data: any) {
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = new Text(data.title);
|
||||
this.contents = new Text(data.contents);
|
||||
|
||||
Reference in New Issue
Block a user