refactor!: overhaul core classes and remove redundant code (#388)

* feat(Player.ts): append `cver` to deciphered URLs

* refactor(Actions.ts): remove redundant `getVideoInfo` function

This is leftover code from previous versions. It had many problems and it is no longer required.

* fix(Kids.ts): remove unneeded `await` keywords

* dev: add more endpoints

* chore: update deps

* refactor: separate endpoints into files

* dev: improve types

* dev: add more endpoints

* refactor: put clients in a separate directory inside `core`

* chore: lint

* refactor: move mixins and managers to separate folders

* chore: fix tests

* dev: add `CreateVideoEndpoint`

* chore: clean up

* chore: lint

* chore: add some comments

* chore: remove unnecessary test

* dev: add `playlist/CreateEndpoint`

* dev: add `playlist/DeleteEndpoint`

* dev: add `browse/EditPlaylistEndpoint`

* fix(parser): add a few checks to avoid parsing errors
This commit is contained in:
LuanRT
2023-04-28 19:01:04 -03:00
committed by GitHub
parent 22ae6c93ee
commit 95e0294eab
83 changed files with 1524 additions and 705 deletions

View File

@@ -26,7 +26,7 @@ export default class InfoPanelContent extends YTNode {
this.truncate_paragraphs = !!data.truncateParagraphs;
this.background = data.background;
if (Reflect.has(data.inlineLinkIcon, 'iconType')) {
if (Reflect.has(data, 'inlineLinkIcon') && Reflect.has(data.inlineLinkIcon, 'iconType')) {
this.inline_link_icon_type = data.inlineLinkIcon.iconType;
}
}

View File

@@ -19,12 +19,14 @@ export class Marker extends YTNode {
this.value = {};
if (Reflect.has(data.value, 'heatmap')) {
this.value.heatmap = Parser.parseItem(data.value.heatmap, Heatmap);
}
if (Reflect.has(data, 'value')) {
if (Reflect.has(data.value, 'heatmap')) {
this.value.heatmap = Parser.parseItem(data.value.heatmap, Heatmap);
}
if (Reflect.has(data.value, 'chapters')) {
this.value.chapters = Parser.parseArray(data.value.chapters, Chapter);
if (Reflect.has(data.value, 'chapters')) {
this.value.chapters = Parser.parseArray(data.value.chapters, Chapter);
}
}
}
}

View File

@@ -17,7 +17,7 @@ export default class AnalyticsVodCarouselCard extends YTNode {
this.no_data_message = data.noDataMessage;
}
if (Reflect.has(data.videoCarouselData, 'videos')) {
if (Reflect.has(data, 'videoCarouselData') && Reflect.has(data.videoCarouselData, 'videos')) {
this.videos = data.videoCarouselData.videos.map((video: RawNode) => new Video(video));
}
}

View File

@@ -21,7 +21,7 @@ export default class CreatorHeart extends YTNode {
super();
this.creator_thumbnail = Thumbnail.fromResponse(data.creatorThumbnail);
if (Reflect.has(data.heartIcon, 'iconType')) {
if (Reflect.has(data, 'heartIcon') && Reflect.has(data.heartIcon, 'iconType')) {
this.heart_icon_type = data.heartIcon.iconType;
}

View File

@@ -20,7 +20,7 @@ export default class PdgCommentChip extends YTNode {
foreground_title_color: data.chipColorPalette?.foregroundTitleColor
};
if (Reflect.has(data.chipIcon, 'iconType')) {
if (Reflect.has(data, 'chipIcon') && Reflect.has(data.chipIcon, 'iconType')) {
this.icon_type = data.chipIcon.iconType;
}
}

View File

@@ -13,7 +13,7 @@ export default class MusicMultiSelectMenu extends YTNode {
constructor(data: RawNode) {
super();
if (Reflect.has(data.title, 'musicMenuTitleRenderer')) {
if (Reflect.has(data, 'title') && Reflect.has(data.title, 'musicMenuTitleRenderer')) {
this.title = new Text(data.title.musicMenuTitleRenderer?.primaryText);
}

View File

@@ -10,7 +10,7 @@ export default class ChildElement extends YTNode {
constructor(data: RawNode) {
super();
if (Reflect.has(data.type, 'textType')) {
if (Reflect.has(data, 'type') && Reflect.has(data.type, 'textType')) {
this.text = data.type.textType.text?.content;
}