mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-25 15:52:13 +00:00
feat(parser): Add AlertWithButton (#486)
This commit is contained in:
19
src/parser/classes/AlertWithButton.ts
Normal file
19
src/parser/classes/AlertWithButton.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import Button from './Button.js';
|
||||
import Text from './misc/Text.js';
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { Parser, type RawNode } from '../index.js';
|
||||
|
||||
export default class AlertWithButton extends YTNode {
|
||||
static type = 'AlertWithButton';
|
||||
|
||||
text: Text;
|
||||
alert_type: string;
|
||||
dismiss_button: Button | null;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.text = new Text(data.text);
|
||||
this.alert_type = data.type;
|
||||
this.dismiss_button = Parser.parseItem(data.dismissButton, Button);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ export { default as AccountSectionList } from './classes/AccountSectionList.js';
|
||||
export { default as AppendContinuationItemsAction } from './classes/actions/AppendContinuationItemsAction.js';
|
||||
export { default as OpenPopupAction } from './classes/actions/OpenPopupAction.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';
|
||||
|
||||
@@ -6,6 +6,7 @@ import PlayerCaptionsTracklist from './classes/PlayerCaptionsTracklist.js';
|
||||
import PlayerLiveStoryboardSpec from './classes/PlayerLiveStoryboardSpec.js';
|
||||
import PlayerStoryboardSpec from './classes/PlayerStoryboardSpec.js';
|
||||
import Alert from './classes/Alert.js';
|
||||
import AlertWithButton from './classes/AlertWithButton.js';
|
||||
|
||||
import type { IParsedResponse, IRawResponse, RawData, RawNode } from './types/index.js';
|
||||
|
||||
@@ -310,7 +311,7 @@ export function parseResponse<T extends IParsedResponse = IParsedResponse>(data:
|
||||
parsed_data.overlay = overlay;
|
||||
}
|
||||
|
||||
const alerts = parseArray(data.alerts, Alert);
|
||||
const alerts = parseArray(data.alerts, [ Alert, AlertWithButton ]);
|
||||
if (alerts.length) {
|
||||
parsed_data.alerts = alerts;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import type PlayerLiveStoryboardSpec from '../classes/PlayerLiveStoryboardSpec.j
|
||||
import type PlayerStoryboardSpec from '../classes/PlayerStoryboardSpec.js';
|
||||
import type VideoDetails from '../classes/misc/VideoDetails.js';
|
||||
import type Alert from '../classes/Alert.js';
|
||||
import type AlertWithButton from '../classes/AlertWithButton.js';
|
||||
import type NavigationEndpoint from '../classes/NavigationEndpoint.js';
|
||||
import type PlayerAnnotationsExpanded from '../classes/PlayerAnnotationsExpanded.js';
|
||||
import type EngagementPanelSectionList from '../classes/EngagementPanelSectionList.js';
|
||||
@@ -44,7 +45,7 @@ export interface IParsedResponse {
|
||||
metadata?: SuperParsedResult<YTNode>;
|
||||
microformat?: YTNode;
|
||||
overlay?: YTNode;
|
||||
alerts?: ObservedArray<Alert>;
|
||||
alerts?: ObservedArray<Alert | AlertWithButton>;
|
||||
refinements?: string[];
|
||||
estimated_results?: number;
|
||||
player_overlays?: SuperParsedResult<YTNode>;
|
||||
@@ -122,7 +123,7 @@ export interface IBrowseResponse {
|
||||
header_memo?: Memo;
|
||||
metadata?: SuperParsedResult<YTNode>;
|
||||
microformat?: YTNode;
|
||||
alerts?: ObservedArray<Alert>;
|
||||
alerts?: ObservedArray<Alert | AlertWithButton>;
|
||||
sidebar?: YTNode;
|
||||
sidebar_memo?: Memo;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user