From cfc1a183e05de6dff979ad884260abf0d03b764e Mon Sep 17 00:00:00 2001 From: Chinmay Kumar <37647219+chinmay021@users.noreply.github.com> Date: Tue, 7 Mar 2023 10:32:07 +0530 Subject: [PATCH] refactor(parser): type YTNodes' data arg as `RawNode` (wip) (#339) * replaced YTNode's data arg as RawNode * updated documentation * removed unused import ---- Note that there are still many nodes that need to be updated, hence the WIP status. --- docs/updating-the-parser.md | 14 +++++++++----- src/parser/classes/AccountChannel.ts | 3 ++- src/parser/classes/AccountItemSection.ts | 5 +++-- src/parser/classes/AccountItemSectionHeader.ts | 4 ++-- src/parser/classes/AccountSectionList.ts | 4 ++-- src/parser/classes/Alert.ts | 4 ++-- src/parser/classes/AudioOnlyPlayability.ts | 4 ++-- src/parser/classes/AutomixPreviewVideo.ts | 4 ++-- .../actions/AppendContinuationItemsAction.ts | 3 ++- src/parser/classes/actions/OpenPopupAction.ts | 3 ++- .../analytics/AnalyticsMainAppKeyMetrics.ts | 3 ++- src/parser/classes/analytics/AnalyticsRoot.ts | 3 ++- .../analytics/AnalyticsShortsCarouselCard.ts | 3 ++- src/parser/classes/analytics/AnalyticsVideo.ts | 3 ++- .../classes/analytics/AnalyticsVodCarouselCard.ts | 3 ++- .../classes/analytics/CtaGoToCreatorStudio.ts | 3 ++- src/parser/classes/analytics/DataModelSection.ts | 3 ++- src/parser/classes/analytics/StatRow.ts | 3 ++- src/parser/classes/comments/AuthorCommentBadge.ts | 3 ++- src/parser/classes/comments/Comment.ts | 3 ++- .../classes/comments/CommentActionButtons.ts | 3 ++- src/parser/classes/comments/CommentDialog.ts | 3 ++- src/parser/classes/comments/CommentReplies.ts | 4 ++-- src/parser/classes/comments/CommentReplyDialog.ts | 3 ++- src/parser/classes/comments/CommentSimplebox.ts | 3 ++- src/parser/classes/comments/CommentThread.ts | 3 ++- .../classes/comments/CommentsEntryPointHeader.ts | 3 ++- src/parser/classes/comments/CommentsHeader.ts | 3 ++- src/parser/classes/comments/CreatorHeart.ts | 3 ++- src/parser/classes/comments/EmojiPicker.ts | 3 ++- src/parser/classes/comments/PdgCommentChip.ts | 3 ++- src/parser/classes/comments/SponsorCommentBadge.ts | 3 ++- .../classes/livechat/AddBannerToLiveChatCommand.ts | 3 ++- src/parser/classes/livechat/AddChatItemAction.ts | 3 ++- .../livechat/AddLiveChatTickerItemAction.ts | 3 ++- src/parser/classes/livechat/DimChatItemAction.ts | 4 ++-- src/parser/classes/livechat/LiveChatActionPanel.ts | 4 ++-- .../livechat/MarkChatItemAsDeletedAction.ts | 4 ++-- .../MarkChatItemsByAuthorAsDeletedAction.ts | 4 ++-- .../livechat/RemoveBannerForLiveChatCommand.ts | 4 ++-- .../classes/livechat/RemoveChatItemAction.ts | 4 ++-- .../livechat/RemoveChatItemByAuthorAction.ts | 4 ++-- .../classes/livechat/ReplaceChatItemAction.ts | 4 ++-- .../classes/livechat/ReplayChatItemAction.ts | 4 ++-- .../livechat/ShowLiveChatActionPanelAction.ts | 4 ++-- .../classes/livechat/ShowLiveChatDialogAction.ts | 4 ++-- .../classes/livechat/ShowLiveChatTooltipCommand.ts | 4 ++-- .../classes/livechat/UpdateDateTextAction.ts | 4 ++-- .../classes/livechat/UpdateDescriptionAction.ts | 4 ++-- .../classes/livechat/UpdateLiveChatPollAction.ts | 4 ++-- src/parser/classes/livechat/UpdateTitleAction.ts | 4 ++-- .../livechat/UpdateToggleButtonTextAction.ts | 4 ++-- .../classes/livechat/UpdateViewershipAction.ts | 4 ++-- .../livechat/items/LiveChatAutoModMessage.ts | 3 ++- .../classes/livechat/items/LiveChatBanner.ts | 3 ++- .../classes/livechat/items/LiveChatBannerHeader.ts | 3 ++- .../classes/livechat/items/LiveChatBannerPoll.ts | 4 ++-- .../livechat/items/LiveChatMembershipItem.ts | 4 ++-- .../classes/livechat/items/LiveChatPaidMessage.ts | 4 ++-- .../classes/livechat/items/LiveChatPaidSticker.ts | 3 ++- .../livechat/items/LiveChatPlaceholderItem.ts | 3 ++- .../classes/livechat/items/LiveChatProductItem.ts | 3 ++- .../items/LiveChatRestrictedParticipation.ts | 3 ++- .../classes/livechat/items/LiveChatTextMessage.ts | 3 ++- .../items/LiveChatTickerPaidMessageItem.ts | 3 ++- .../items/LiveChatTickerPaidStickerItem.ts | 3 ++- .../livechat/items/LiveChatTickerSponsorItem.ts | 3 ++- .../items/LiveChatViewerEngagementMessage.ts | 3 ++- src/parser/classes/livechat/items/PollHeader.ts | 3 ++- src/parser/classes/menus/Menu.ts | 4 ++-- src/parser/classes/menus/MenuNavigationItem.ts | 4 ++-- src/parser/classes/menus/MenuServiceItem.ts | 4 ++-- .../classes/menus/MenuServiceItemDownload.ts | 4 ++-- src/parser/classes/menus/MultiPageMenu.ts | 4 ++-- .../menus/MultiPageMenuNotificationSection.ts | 4 ++-- src/parser/classes/menus/MusicMenuItemDivider.ts | 4 ++-- src/parser/classes/menus/MusicMultiSelectMenu.ts | 4 ++-- .../classes/menus/MusicMultiSelectMenuItem.ts | 4 ++-- src/parser/classes/menus/SimpleMenuHeader.ts | 4 ++-- src/parser/classes/misc/ChildElement.ts | 4 +++- src/parser/classes/misc/EmojiRun.ts | 3 ++- src/parser/classes/misc/Format.ts | 3 ++- src/parser/classes/misc/NavigatableText.ts | 3 ++- src/parser/classes/misc/Text.ts | 3 ++- src/parser/classes/misc/Thumbnail.ts | 4 +++- src/parser/classes/misc/VideoDetails.ts | 3 ++- src/parser/classes/ytkids/AnchoredSection.ts | 3 ++- src/parser/classes/ytkids/KidsCategoriesHeader.ts | 3 ++- src/parser/classes/ytkids/KidsCategoryTab.ts | 3 ++- src/parser/classes/ytkids/KidsHomeScreen.ts | 3 ++- 90 files changed, 190 insertions(+), 132 deletions(-) diff --git a/docs/updating-the-parser.md b/docs/updating-the-parser.md index b392f712..45a04ad8 100644 --- a/docs/updating-the-parser.md +++ b/docs/updating-the-parser.md @@ -1,8 +1,9 @@ # Updating the parser -YouTube is constantly changing, so it is not rare to see YouTube crawlers/scrapers breaking every now and then. +YouTube is constantly changing, so it is not rare to see YouTube crawlers/scrapers breaking every now and then. + +Our parser, on the other hand, was written so that it behaves similarly to an official client, parsing and mapping renderers (a.k.a YTNodes) dynamically without hard-coding their path in the response. This way, whenever a new renderer pops up (e.g; YouTube adds a new feature / minor UI changes) the library will print a warning similar to this: -Our parser, on the other hand, was written so that it behaves similarly to an official client, parsing and mapping renderers (a.k.a YTNodes) dynamically without hard-coding their path in the response. This way, whenever a new renderer pops up (e.g; YouTube adds a new feature / minor UI changes) the library will print a warning similar to this: ``` InnertubeError: SomeRenderer not found! This is a bug, want to help us fix it? Follow the instructions at https://github.com/LuanRT/YouTube.js/blob/main/docs/updating-the-parser.md or report it at https://github.com/LuanRT/YouTube.js/issues! @@ -26,17 +27,19 @@ Thanks to the modularity of the parser, a renderer can be implemented by simply For example, say we found a new renderer named `verticalListRenderer`, to let the parser know it exists we would have to create a file with the following structure: > `../classes/VerticalList.ts` + ```ts import Parser from '..'; import { YTNode } from '../helpers'; +import type { RawNode } from '../index.js'; class VerticalList extends YTNode { static type = 'VerticalList'; - + header; contents; - constructor(data: any) { + constructor(data: RawNode) { // parse the data here, ex; this.header = Parser.parseItem(data.header); this.contents = Parser.parseArray(data.contents); @@ -47,8 +50,9 @@ export default VerticalList; ``` Then update the parser map: + ```bash npm run build:parser-map ``` -And that's it! \ No newline at end of file +And that's it! diff --git a/src/parser/classes/AccountChannel.ts b/src/parser/classes/AccountChannel.ts index cec2b19f..6c3af847 100644 --- a/src/parser/classes/AccountChannel.ts +++ b/src/parser/classes/AccountChannel.ts @@ -1,6 +1,7 @@ import Text from './misc/Text.js'; import NavigationEndpoint from './NavigationEndpoint.js'; import { YTNode } from '../helpers.js'; +import type { RawNode } from '../index.js'; class AccountChannel extends YTNode { static type = 'AccountChannel'; @@ -8,7 +9,7 @@ class AccountChannel extends YTNode { title: Text; endpoint: NavigationEndpoint; - constructor(data: any) { + constructor(data: RawNode) { super(); this.title = new Text(data.title); this.endpoint = new NavigationEndpoint(data.navigationEndpoint); diff --git a/src/parser/classes/AccountItemSection.ts b/src/parser/classes/AccountItemSection.ts index 40daceb1..89aa7d5b 100644 --- a/src/parser/classes/AccountItemSection.ts +++ b/src/parser/classes/AccountItemSection.ts @@ -6,6 +6,7 @@ import NavigationEndpoint from './NavigationEndpoint.js'; import AccountItemSectionHeader from './AccountItemSectionHeader.js'; import { YTNode } from '../helpers.js'; +import type { RawNode } from '../index.js'; class AccountItem { static type = 'AccountItem'; @@ -18,7 +19,7 @@ class AccountItem { endpoint: NavigationEndpoint; account_byline: Text; - constructor(data: any) { + constructor(data: RawNode) { this.account_name = new Text(data.accountName); this.account_photo = Thumbnail.fromResponse(data.accountPhoto); this.is_selected = data.isSelected; @@ -35,7 +36,7 @@ class AccountItemSection extends YTNode { contents; header; - constructor(data: any) { + constructor(data: RawNode) { super(); this.contents = data.contents.map((ac: any) => new AccountItem(ac.accountItem)); this.header = Parser.parseItem(data.header, AccountItemSectionHeader); diff --git a/src/parser/classes/AccountItemSectionHeader.ts b/src/parser/classes/AccountItemSectionHeader.ts index 91d40edb..1653392a 100644 --- a/src/parser/classes/AccountItemSectionHeader.ts +++ b/src/parser/classes/AccountItemSectionHeader.ts @@ -1,12 +1,12 @@ import Text from './misc/Text.js'; import { YTNode } from '../helpers.js'; - +import type { RawNode } from '../index.js'; class AccountItemSectionHeader extends YTNode { static type = 'AccountItemSectionHeader'; title: Text; - constructor(data: any) { + constructor(data: RawNode) { super(); this.title = new Text(data.title); } diff --git a/src/parser/classes/AccountSectionList.ts b/src/parser/classes/AccountSectionList.ts index 03bc27cc..31f54efb 100644 --- a/src/parser/classes/AccountSectionList.ts +++ b/src/parser/classes/AccountSectionList.ts @@ -3,14 +3,14 @@ import AccountChannel from './AccountChannel.js'; import AccountItemSection from './AccountItemSection.js'; import { YTNode } from '../helpers.js'; - +import type { RawNode } from '../index.js'; class AccountSectionList extends YTNode { static type = 'AccountSectionList'; contents; footers; - constructor(data: any) { + constructor(data: RawNode) { super(); this.contents = Parser.parseItem(data.contents[0], AccountItemSection); this.footers = Parser.parseItem(data.footers[0], AccountChannel); diff --git a/src/parser/classes/Alert.ts b/src/parser/classes/Alert.ts index d095bee2..e080d24c 100644 --- a/src/parser/classes/Alert.ts +++ b/src/parser/classes/Alert.ts @@ -1,13 +1,13 @@ import Text from './misc/Text.js'; import { YTNode } from '../helpers.js'; - +import type { RawNode } from '../index.js'; class Alert extends YTNode { static type = 'Alert'; text: Text; alert_type: string; - constructor(data: any) { + constructor(data: RawNode) { super(); this.text = new Text(data.text); this.alert_type = data.type; diff --git a/src/parser/classes/AudioOnlyPlayability.ts b/src/parser/classes/AudioOnlyPlayability.ts index f1d4ed3a..f5f6daaa 100644 --- a/src/parser/classes/AudioOnlyPlayability.ts +++ b/src/parser/classes/AudioOnlyPlayability.ts @@ -1,11 +1,11 @@ import { YTNode } from '../helpers.js'; - +import type { RawNode } from '../index.js'; class AudioOnlyPlayability extends YTNode { static type = 'AudioOnlyPlayability'; audio_only_availability: string; - constructor (data: any) { + constructor (data: RawNode) { super(); this.audio_only_availability = data.audioOnlyAvailability; } diff --git a/src/parser/classes/AutomixPreviewVideo.ts b/src/parser/classes/AutomixPreviewVideo.ts index e697106f..0759f3fa 100644 --- a/src/parser/classes/AutomixPreviewVideo.ts +++ b/src/parser/classes/AutomixPreviewVideo.ts @@ -1,12 +1,12 @@ import { YTNode } from '../helpers.js'; import NavigationEndpoint from './NavigationEndpoint.js'; - +import type { RawNode } from '../index.js'; class AutomixPreviewVideo extends YTNode { static type = 'AutomixPreviewVideo'; playlist_video?: { endpoint: NavigationEndpoint }; - constructor(data: any) { + constructor(data: RawNode) { super(); if (data?.content?.automixPlaylistVideoRenderer?.navigationEndpoint) { this.playlist_video = { diff --git a/src/parser/classes/actions/AppendContinuationItemsAction.ts b/src/parser/classes/actions/AppendContinuationItemsAction.ts index a9fa6541..5ca0cc00 100644 --- a/src/parser/classes/actions/AppendContinuationItemsAction.ts +++ b/src/parser/classes/actions/AppendContinuationItemsAction.ts @@ -1,5 +1,6 @@ import Parser from '../../index.js'; import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; class AppendContinuationItemsAction extends YTNode { static type = 'AppendContinuationItemsAction'; @@ -7,7 +8,7 @@ class AppendContinuationItemsAction extends YTNode { items; target: string; - constructor(data: any) { + constructor(data: RawNode) { super(); this.items = Parser.parse(data.continuationItems); this.target = data.target; diff --git a/src/parser/classes/actions/OpenPopupAction.ts b/src/parser/classes/actions/OpenPopupAction.ts index 9286139e..75c4701e 100644 --- a/src/parser/classes/actions/OpenPopupAction.ts +++ b/src/parser/classes/actions/OpenPopupAction.ts @@ -1,5 +1,6 @@ import Parser from '../../index.js'; import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; class OpenPopupAction extends YTNode { static type = 'OpenPopupAction'; @@ -7,7 +8,7 @@ class OpenPopupAction extends YTNode { popup; popup_type; - constructor(data: any) { + constructor(data: RawNode) { super(); this.popup = Parser.parse(data.popup); this.popup_type = data.popupType; diff --git a/src/parser/classes/analytics/AnalyticsMainAppKeyMetrics.ts b/src/parser/classes/analytics/AnalyticsMainAppKeyMetrics.ts index 31715ed5..526de8e2 100644 --- a/src/parser/classes/analytics/AnalyticsMainAppKeyMetrics.ts +++ b/src/parser/classes/analytics/AnalyticsMainAppKeyMetrics.ts @@ -1,5 +1,6 @@ import DataModelSection from './DataModelSection.js'; import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; class AnalyticsMainAppKeyMetrics extends YTNode { static type = 'AnalyticsMainAppKeyMetrics'; @@ -7,7 +8,7 @@ class AnalyticsMainAppKeyMetrics extends YTNode { period: string; sections: DataModelSection[]; - constructor(data: any) { + constructor(data: RawNode) { super(); this.period = data.cardData.periodLabel; const metrics_data = data.cardData.sections[0].analyticsKeyMetricsData; diff --git a/src/parser/classes/analytics/AnalyticsRoot.ts b/src/parser/classes/analytics/AnalyticsRoot.ts index a4bb3c9f..bd3849b4 100644 --- a/src/parser/classes/analytics/AnalyticsRoot.ts +++ b/src/parser/classes/analytics/AnalyticsRoot.ts @@ -1,4 +1,5 @@ import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; class AnalyticsRoot extends YTNode { static type = 'AnalyticsRoot'; @@ -19,7 +20,7 @@ class AnalyticsRoot extends YTNode { }[]; }[]; - constructor(data: any) { + constructor(data: RawNode) { super(); const cards = data.analyticsTableCarouselData.data.tableCards; diff --git a/src/parser/classes/analytics/AnalyticsShortsCarouselCard.ts b/src/parser/classes/analytics/AnalyticsShortsCarouselCard.ts index 8ea3048d..ce169ce5 100644 --- a/src/parser/classes/analytics/AnalyticsShortsCarouselCard.ts +++ b/src/parser/classes/analytics/AnalyticsShortsCarouselCard.ts @@ -1,4 +1,5 @@ import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; import NavigationEndpoint from '../NavigationEndpoint.js'; class AnalyticsShortsCarouselCard extends YTNode { @@ -11,7 +12,7 @@ class AnalyticsShortsCarouselCard extends YTNode { endpoint: NavigationEndpoint; }[]; - constructor(data: any) { + constructor(data: RawNode) { super(); this.title = data.title; this.shorts = data.shortsCarouselData.shorts.map((short: any) => ({ diff --git a/src/parser/classes/analytics/AnalyticsVideo.ts b/src/parser/classes/analytics/AnalyticsVideo.ts index b17da865..09b9334d 100644 --- a/src/parser/classes/analytics/AnalyticsVideo.ts +++ b/src/parser/classes/analytics/AnalyticsVideo.ts @@ -1,5 +1,6 @@ import Thumbnail from '../misc/Thumbnail.js'; import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; class AnalyticsVideo extends YTNode { static type = 'AnalyticsVideo'; @@ -13,7 +14,7 @@ class AnalyticsVideo extends YTNode { is_short: boolean; }; - constructor(data: any) { + constructor(data: RawNode) { super(); this.title = data.videoTitle; diff --git a/src/parser/classes/analytics/AnalyticsVodCarouselCard.ts b/src/parser/classes/analytics/AnalyticsVodCarouselCard.ts index 27a98a19..a77e54d7 100644 --- a/src/parser/classes/analytics/AnalyticsVodCarouselCard.ts +++ b/src/parser/classes/analytics/AnalyticsVodCarouselCard.ts @@ -1,5 +1,6 @@ import Video from './AnalyticsVideo.js'; import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; class AnalyticsVodCarouselCard extends YTNode { static type = 'AnalyticsVodCarouselCard'; @@ -8,7 +9,7 @@ class AnalyticsVodCarouselCard extends YTNode { videos: Video[] | null; no_data_message?: string; - constructor(data: any) { + constructor(data: RawNode) { super(); this.title = data.title; diff --git a/src/parser/classes/analytics/CtaGoToCreatorStudio.ts b/src/parser/classes/analytics/CtaGoToCreatorStudio.ts index 3d259557..f2378edc 100644 --- a/src/parser/classes/analytics/CtaGoToCreatorStudio.ts +++ b/src/parser/classes/analytics/CtaGoToCreatorStudio.ts @@ -1,4 +1,5 @@ import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; class CtaGoToCreatorStudio extends YTNode { static type = 'CtaGoToCreatorStudio'; @@ -6,7 +7,7 @@ class CtaGoToCreatorStudio extends YTNode { title: string; use_new_specs: boolean; - constructor(data: any) { + constructor(data: RawNode) { super(); this.title = data.buttonLabel; this.use_new_specs = data.useNewSpecs; diff --git a/src/parser/classes/analytics/DataModelSection.ts b/src/parser/classes/analytics/DataModelSection.ts index d0967343..cbc71644 100644 --- a/src/parser/classes/analytics/DataModelSection.ts +++ b/src/parser/classes/analytics/DataModelSection.ts @@ -1,4 +1,5 @@ import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; class DataModelSection extends YTNode { static type = 'DataModelSection'; @@ -36,7 +37,7 @@ class DataModelSection extends YTNode { } }; - constructor(data: any) { + constructor(data: RawNode) { super(); this.title = data.title; diff --git a/src/parser/classes/analytics/StatRow.ts b/src/parser/classes/analytics/StatRow.ts index d0bf0f22..cea7e738 100644 --- a/src/parser/classes/analytics/StatRow.ts +++ b/src/parser/classes/analytics/StatRow.ts @@ -1,6 +1,7 @@ import Text from '../misc/Text.js'; import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; class StatRow extends YTNode { static type = 'StatRow'; @@ -8,7 +9,7 @@ class StatRow extends YTNode { title: Text; contents: Text; - constructor(data: any) { + constructor(data: RawNode) { super(); this.title = new Text(data.title); this.contents = new Text(data.contents); diff --git a/src/parser/classes/comments/AuthorCommentBadge.ts b/src/parser/classes/comments/AuthorCommentBadge.ts index f15098b4..6d04a88b 100644 --- a/src/parser/classes/comments/AuthorCommentBadge.ts +++ b/src/parser/classes/comments/AuthorCommentBadge.ts @@ -1,4 +1,5 @@ import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; class AuthorCommentBadge extends YTNode { static type = 'AuthorCommentBadge'; @@ -9,7 +10,7 @@ class AuthorCommentBadge extends YTNode { tooltip: string; style?: string; - constructor(data: any) { + constructor(data: RawNode) { super(); this.icon_type = data.icon?.iconType || null; diff --git a/src/parser/classes/comments/Comment.ts b/src/parser/classes/comments/Comment.ts index 3a787593..d9ea0be2 100644 --- a/src/parser/classes/comments/Comment.ts +++ b/src/parser/classes/comments/Comment.ts @@ -16,6 +16,7 @@ import type Actions from '../../../core/Actions.js'; import Proto from '../../../proto/index.js'; import { InnertubeError } from '../../../utils/Utils.js'; import { YTNode, SuperParsedResult } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; class Comment extends YTNode { static type = 'Comment'; @@ -44,7 +45,7 @@ class Comment extends YTNode { is_pinned: boolean; is_member: boolean; - constructor(data: any) { + constructor(data: RawNode) { super(); this.content = new Text(data.contentText); this.published = new Text(data.publishedTimeText); diff --git a/src/parser/classes/comments/CommentActionButtons.ts b/src/parser/classes/comments/CommentActionButtons.ts index 94732f86..5e77be74 100644 --- a/src/parser/classes/comments/CommentActionButtons.ts +++ b/src/parser/classes/comments/CommentActionButtons.ts @@ -3,6 +3,7 @@ import type Button from '../Button.js'; import type ToggleButton from '../ToggleButton.js'; import type CreatorHeart from './CreatorHeart.js'; import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; class CommentActionButtons extends YTNode { static type = 'CommentActionButtons'; @@ -12,7 +13,7 @@ class CommentActionButtons extends YTNode { reply_button; creator_heart; - constructor(data: any) { + constructor(data: RawNode) { super(); this.like_button = Parser.parseItem(data.likeButton); this.dislike_button = Parser.parseItem(data.dislikeButton); diff --git a/src/parser/classes/comments/CommentDialog.ts b/src/parser/classes/comments/CommentDialog.ts index 6144c6b2..c0b7459b 100644 --- a/src/parser/classes/comments/CommentDialog.ts +++ b/src/parser/classes/comments/CommentDialog.ts @@ -4,6 +4,7 @@ import Thumbnail from '../misc/Thumbnail.js'; import type Button from '../Button.js'; import type EmojiPicker from './EmojiPicker.js'; import { YTNode } from '../../helpers.js'; +import type { RawNode } from '../../index.js'; class CommentDialog extends YTNode { static type = 'CommentDialog'; @@ -16,7 +17,7 @@ class CommentDialog extends YTNode { emoji_button: Button | null; emoji_picker: any | null; - constructor(data: any) { + constructor(data: RawNode) { super(); this.editable_text = new Text(data.editableText); this.author_thumbnail = Thumbnail.fromResponse(data.authorThumbnail); diff --git a/src/parser/classes/comments/CommentReplies.ts b/src/parser/classes/comments/CommentReplies.ts index 24bccd40..d8084942 100644 --- a/src/parser/classes/comments/CommentReplies.ts +++ b/src/parser/classes/comments/CommentReplies.ts @@ -2,7 +2,7 @@ import Parser from '../../index.js'; import Thumbnail from '../misc/Thumbnail.js'; import type Button from '../Button.js'; import { YTNode } from '../../helpers.js'; - +import type { RawNode } from '../../index.js'; class CommentReplies extends YTNode { static type = 'CommentReplies'; @@ -12,7 +12,7 @@ class CommentReplies extends YTNode { view_replies_creator_thumbnail: Thumbnail[]; has_channel_owner_replied: boolean; - constructor(data: any) { + constructor(data: RawNode) { super(); this.contents = Parser.parseArray(data.contents); this.view_replies = Parser.parseItem