refactor: clean up parser and tests (#387)

* tests: improve coverage

* refactor: clean up nodes

* chore: lint

* feat(parser): ignore `BrandVideoShelf`

Seems to be used for ads.

* feat(parser): ignore `BrandVideoSingleton` too
This commit is contained in:
LuanRT
2023-04-23 06:37:33 -03:00
committed by GitHub
parent f66f0bd656
commit 257bd475a0
358 changed files with 2823 additions and 3126 deletions

View File

@@ -1,9 +1,9 @@
import Text from './misc/Text.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Text from './misc/Text.js';
class SettingBoolean extends YTNode {
export default class SettingBoolean extends YTNode {
static type = 'SettingBoolean';
title?: Text;
@@ -12,27 +12,24 @@ class SettingBoolean extends YTNode {
disable_endpoint?: NavigationEndpoint;
item_id: string;
constructor(data: any) {
constructor(data: RawNode) {
super();
if (data.title) {
if (Reflect.has(data, 'title')) {
this.title = new Text(data.title);
}
if (data.summary) {
if (Reflect.has(data, 'summary')) {
this.summary = new Text(data.summary);
}
if (data.enableServiceEndpoint) {
if (Reflect.has(data, 'enableServiceEndpoint')) {
this.enable_endpoint = new NavigationEndpoint(data.enableServiceEndpoint);
}
if (data.disableServiceEndpoint) {
if (Reflect.has(data, 'disableServiceEndpoint')) {
this.disable_endpoint = new NavigationEndpoint(data.disableServiceEndpoint);
}
this.item_id = data.itemId;
}
}
export default SettingBoolean;
}