From c1de097ce1182b7bd26e0dc8ead5f9bd23eff46a Mon Sep 17 00:00:00 2001 From: Luan Date: Tue, 10 Dec 2024 16:30:23 -0300 Subject: [PATCH] chore(Parser): Don't ignore `BackgroundPromo` It turns out this is not an ad at all. --- src/core/Actions.ts | 3 +++ src/parser/classes/BackgroundPromo.ts | 25 +++++++++++++++++++++++++ src/parser/nodes.ts | 1 + src/parser/parser.ts | 1 - 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/parser/classes/BackgroundPromo.ts diff --git a/src/core/Actions.ts b/src/core/Actions.ts index 0eaa0c42..3fd90320 100644 --- a/src/core/Actions.ts +++ b/src/core/Actions.ts @@ -117,6 +117,9 @@ export default class Actions { if (this.#needsLogin(data.browseId) && !this.session.logged_in) throw new InnertubeError('You must be signed in to perform this operation.'); } + + if (Reflect.has(data, 'skip_auth_check')) + delete data.skip_auth_check; if (Reflect.has(data, 'override_endpoint')) delete data.override_endpoint; diff --git a/src/parser/classes/BackgroundPromo.ts b/src/parser/classes/BackgroundPromo.ts new file mode 100644 index 00000000..6e7e7f6a --- /dev/null +++ b/src/parser/classes/BackgroundPromo.ts @@ -0,0 +1,25 @@ +import { YTNode } from '../helpers.js'; +import { Parser, type RawNode } from '../index.js'; +import Text from './misc/Text.js'; +import Button from './Button.js'; +import ButtonView from './ButtonView.js'; + +export default class BackgroundPromo extends YTNode { + static type = 'BackgroundPromo'; + + public body_text?: Text; + public cta_button?: Button | ButtonView | null; + public icon_type?: string; + public title?: Text; + + constructor(data: RawNode) { + super(); + this.body_text = new Text(data.bodyText); + this.cta_button = Parser.parseItem(data.ctaButton, [ Button, ButtonView ]); + + if (Reflect.has(data, 'icon')) + this.icon_type = data.icon.iconType; + + this.title = new Text(data.title); + } +} \ No newline at end of file diff --git a/src/parser/nodes.ts b/src/parser/nodes.ts index 56e3e3c1..579a4614 100644 --- a/src/parser/nodes.ts +++ b/src/parser/nodes.ts @@ -24,6 +24,7 @@ export { default as AttributionView } from './classes/AttributionView.js'; export { default as AudioOnlyPlayability } from './classes/AudioOnlyPlayability.js'; export { default as AutomixPreviewVideo } from './classes/AutomixPreviewVideo.js'; export { default as AvatarView } from './classes/AvatarView.js'; +export { default as BackgroundPromo } from './classes/BackgroundPromo.js'; export { default as BackstageImage } from './classes/BackstageImage.js'; export { default as BackstagePost } from './classes/BackstagePost.js'; export { default as BackstagePostThread } from './classes/BackstagePostThread.js'; diff --git a/src/parser/parser.ts b/src/parser/parser.ts index 1e87891a..f8577268 100644 --- a/src/parser/parser.ts +++ b/src/parser/parser.ts @@ -76,7 +76,6 @@ const IGNORED_LIST = new Set([ 'SearchPyv', 'MealbarPromo', 'PrimetimePromo', - 'BackgroundPromo', 'PromotedSparklesWeb', 'CompactPromotedVideo', 'BrandVideoShelf',