mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-07-02 04:58:42 +00:00
refactor(parser): Remove unused analytics nodes
These were once useful when it was still possible to use the Android client with OAuth.
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
import DataModelSection from './DataModelSection.js';
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
export default class AnalyticsMainAppKeyMetrics extends YTNode {
|
||||
static type = 'AnalyticsMainAppKeyMetrics';
|
||||
|
||||
period: string;
|
||||
sections: DataModelSection[];
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.period = data.cardData.periodLabel;
|
||||
|
||||
const metrics_data = data.cardData.sections[0].analyticsKeyMetricsData;
|
||||
|
||||
this.sections = metrics_data.dataModel.sections.map(
|
||||
(section: any) => new DataModelSection(section)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
export default 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;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import NavigationEndpoint from '../NavigationEndpoint.js';
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
export default class AnalyticsShortsCarouselCard extends YTNode {
|
||||
static type = 'AnalyticsShortsCarouselCard';
|
||||
|
||||
title: string;
|
||||
shorts: {
|
||||
description: string;
|
||||
thumbnail_url: string;
|
||||
endpoint: NavigationEndpoint;
|
||||
}[];
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = data.title;
|
||||
this.shorts = data.shortsCarouselData.shorts.map((short: any) => ({
|
||||
description: short.shortsDescription,
|
||||
thumbnail_url: short.thumbnailUrl,
|
||||
endpoint: new NavigationEndpoint(short.videoEndpoint)
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
import Thumbnail from '../misc/Thumbnail.js';
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
export default class AnalyticsVideo extends YTNode {
|
||||
static type = 'AnalyticsVideo';
|
||||
|
||||
title: string;
|
||||
metadata: {
|
||||
views: string;
|
||||
published: string;
|
||||
thumbnails: Thumbnail[];
|
||||
duration: string;
|
||||
is_short: boolean;
|
||||
};
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = data.videoTitle;
|
||||
|
||||
this.metadata = {
|
||||
views: data.videoDescription.split('·')[0].trim(),
|
||||
published: data.videoDescription.split('·')[1].trim(),
|
||||
thumbnails: Thumbnail.fromResponse(data.thumbnailDetails),
|
||||
duration: data.formattedLength,
|
||||
is_short: data.isShort
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import Video from './AnalyticsVideo.js';
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
export default class AnalyticsVodCarouselCard extends YTNode {
|
||||
static type = 'AnalyticsVodCarouselCard';
|
||||
|
||||
title: string;
|
||||
videos?: Video[];
|
||||
no_data_message?: string;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = data.title;
|
||||
|
||||
if (Reflect.has(data, 'noDataMessage')) {
|
||||
this.no_data_message = data.noDataMessage;
|
||||
}
|
||||
|
||||
if (Reflect.has(data, 'videoCarouselData') && Reflect.has(data.videoCarouselData, 'videos')) {
|
||||
this.videos = data.videoCarouselData.videos.map((video: RawNode) => new Video(video));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
export default class CtaGoToCreatorStudio extends YTNode {
|
||||
static type = 'CtaGoToCreatorStudio';
|
||||
|
||||
title: string;
|
||||
use_new_specs: boolean;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = data.buttonLabel;
|
||||
this.use_new_specs = data.useNewSpecs;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
export default class DataModelSection extends YTNode {
|
||||
static type = 'DataModelSection';
|
||||
|
||||
title: string;
|
||||
subtitle: string;
|
||||
metric_value: string;
|
||||
|
||||
comparison_indicator: {
|
||||
trend: string;
|
||||
};
|
||||
|
||||
series_configuration: {
|
||||
line_series: {
|
||||
lines_data: {
|
||||
x: number[];
|
||||
y: number[];
|
||||
style: {
|
||||
line_width: number;
|
||||
line_color: number;
|
||||
}
|
||||
}
|
||||
domain_axis: {
|
||||
tick_values: number[];
|
||||
custom_formatter: {
|
||||
labels: string[];
|
||||
}
|
||||
}
|
||||
measure_axis: {
|
||||
tick_values: number[];
|
||||
custom_formatter: {
|
||||
labels: string[];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.title = data.title;
|
||||
this.subtitle = data.subtitle;
|
||||
this.metric_value = data.metricValue;
|
||||
this.comparison_indicator = data.comparisonIndicator;
|
||||
|
||||
const line_series = data.seriesConfiguration.lineSeries;
|
||||
|
||||
this.series_configuration = {
|
||||
line_series: {
|
||||
lines_data: {
|
||||
x: line_series.linesData[0].x,
|
||||
y: line_series.linesData[0].y,
|
||||
style: {
|
||||
line_width: line_series.linesData[0].style.lineWidth,
|
||||
line_color: line_series.linesData[0].style.lineColor
|
||||
}
|
||||
},
|
||||
domain_axis: {
|
||||
tick_values: line_series.domainAxis.tickValues,
|
||||
custom_formatter: line_series.domainAxis.customFormatter
|
||||
},
|
||||
measure_axis: {
|
||||
tick_values: line_series.measureAxis.tickValues,
|
||||
custom_formatter: line_series.measureAxis.customFormatter
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import Text from '../misc/Text.js';
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
export default class StatRow extends YTNode {
|
||||
static type = 'StatRow';
|
||||
|
||||
title: Text;
|
||||
contents: Text;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = new Text(data.title);
|
||||
this.contents = new Text(data.contents);
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,6 @@ export { default as UpdateSubscribeButtonAction } from './classes/actions/Update
|
||||
export { default as AddToPlaylist } from './classes/AddToPlaylist.js';
|
||||
export { default as Alert } from './classes/Alert.js';
|
||||
export { default as AlertWithButton } from './classes/AlertWithButton.js';
|
||||
export { default as AnalyticsMainAppKeyMetrics } from './classes/analytics/AnalyticsMainAppKeyMetrics.js';
|
||||
export { default as AnalyticsRoot } from './classes/analytics/AnalyticsRoot.js';
|
||||
export { default as AnalyticsShortsCarouselCard } from './classes/analytics/AnalyticsShortsCarouselCard.js';
|
||||
export { default as AnalyticsVideo } from './classes/analytics/AnalyticsVideo.js';
|
||||
export { default as AnalyticsVodCarouselCard } from './classes/analytics/AnalyticsVodCarouselCard.js';
|
||||
export { default as CtaGoToCreatorStudio } from './classes/analytics/CtaGoToCreatorStudio.js';
|
||||
export { default as DataModelSection } from './classes/analytics/DataModelSection.js';
|
||||
export { default as StatRow } from './classes/analytics/StatRow.js';
|
||||
export { default as AttributionView } from './classes/AttributionView.js';
|
||||
export { default as AudioOnlyPlayability } from './classes/AudioOnlyPlayability.js';
|
||||
export { default as AutomixPreviewVideo } from './classes/AutomixPreviewVideo.js';
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { Parser } from '../index.js';
|
||||
import Element from '../classes/Element.js';
|
||||
import type { ApiResponse } from '../../core/index.js';
|
||||
import type { IBrowseResponse } from '../types/index.js';
|
||||
|
||||
export default class Analytics {
|
||||
#page: IBrowseResponse;
|
||||
sections;
|
||||
|
||||
constructor(response: ApiResponse) {
|
||||
this.#page = Parser.parseResponse<IBrowseResponse>(response.data);
|
||||
this.sections = this.#page.contents_memo?.getType(Element).map((el) => el.model).flatMap((el) => !el ? [] : el);
|
||||
}
|
||||
|
||||
get page(): IBrowseResponse {
|
||||
return this.#page;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import { Parser } from '../index.js';
|
||||
import ItemSection from '../classes/ItemSection.js';
|
||||
import SectionList from '../classes/SectionList.js';
|
||||
import SingleColumnBrowseResults from '../classes/SingleColumnBrowseResults.js';
|
||||
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import type { ApiResponse } from '../../core/index.js';
|
||||
import type { ObservedArray } from '../helpers.js';
|
||||
import type { IBrowseResponse } from '../types/index.js';
|
||||
|
||||
export default class TimeWatched {
|
||||
#page: IBrowseResponse;
|
||||
contents?: ObservedArray<ItemSection>;
|
||||
|
||||
constructor(response: ApiResponse) {
|
||||
this.#page = Parser.parseResponse<IBrowseResponse>(response.data);
|
||||
|
||||
if (!this.#page.contents)
|
||||
throw new InnertubeError('Page contents not found');
|
||||
|
||||
const tab = this.#page.contents.item().as(SingleColumnBrowseResults).tabs.get({ selected: true });
|
||||
|
||||
if (!tab)
|
||||
throw new InnertubeError('Could not find target tab.');
|
||||
|
||||
this.contents = tab.content?.as(SectionList).contents.as(ItemSection);
|
||||
}
|
||||
|
||||
get page(): IBrowseResponse {
|
||||
return this.#page;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
export { default as AccountInfo } from './AccountInfo.js';
|
||||
export { default as Analytics } from './Analytics.js';
|
||||
export { default as Channel } from './Channel.js';
|
||||
export * from './Channel.js';
|
||||
export { default as Comments } from './Comments.js';
|
||||
@@ -15,6 +14,5 @@ export { default as Playlist } from './Playlist.js';
|
||||
export { default as Search } from './Search.js';
|
||||
export { default as Settings } from './Settings.js';
|
||||
export { default as SmoothedQueue } from './SmoothedQueue.js';
|
||||
export { default as TimeWatched } from './TimeWatched.js';
|
||||
export { default as VideoInfo } from './VideoInfo.js';
|
||||
export { default as TranscriptInfo } from './TranscriptInfo.js';
|
||||
Reference in New Issue
Block a user