From 257bd475a026ff4c03a30fe0f4b1c6b2a9101883 Mon Sep 17 00:00:00 2001 From: LuanRT Date: Sun, 23 Apr 2023 06:37:33 -0300 Subject: [PATCH] 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 --- src/core/Music.ts | 11 +- src/parser/classes/AccountChannel.ts | 6 +- src/parser/classes/AccountItemSection.ts | 31 +- .../classes/AccountItemSectionHeader.ts | 7 +- src/parser/classes/AccountSectionList.ts | 7 +- src/parser/classes/Alert.ts | 7 +- src/parser/classes/AudioOnlyPlayability.ts | 7 +- src/parser/classes/AutomixPreviewVideo.ts | 7 +- src/parser/classes/BackstageImage.ts | 9 +- src/parser/classes/BackstagePost.ts | 37 +- src/parser/classes/BackstagePostThread.ts | 12 +- src/parser/classes/BrowseFeedActions.ts | 14 +- src/parser/classes/BrowserMediaSession.ts | 13 +- src/parser/classes/Button.ts | 15 +- src/parser/classes/C4TabbedHeader.ts | 40 +- src/parser/classes/CallToActionButton.ts | 9 +- src/parser/classes/Card.ts | 28 +- src/parser/classes/CardCollection.ts | 14 +- src/parser/classes/CarouselHeader.ts | 14 +- src/parser/classes/CarouselItem.ts | 18 +- src/parser/classes/Channel.ts | 49 +- .../classes/ChannelAboutFullMetadata.ts | 45 +- src/parser/classes/ChannelAgeGate.ts | 11 +- src/parser/classes/ChannelFeaturedContent.ts | 12 +- src/parser/classes/ChannelHeaderLinks.ts | 27 +- src/parser/classes/ChannelMetadata.ts | 13 +- src/parser/classes/ChannelMobileHeader.ts | 9 +- src/parser/classes/ChannelOptions.ts | 12 +- src/parser/classes/ChannelSubMenu.ts | 14 +- .../classes/ChannelThumbnailWithLink.ts | 13 +- src/parser/classes/ChannelVideoPlayer.ts | 33 +- src/parser/classes/Chapter.ts | 10 +- src/parser/classes/ChildVideo.ts | 16 +- src/parser/classes/ChipCloud.ts | 22 +- src/parser/classes/ChipCloudChip.ts | 16 +- .../classes/CollaboratorInfoCardContent.ts | 10 +- src/parser/classes/CollageHeroImage.ts | 9 +- src/parser/classes/CompactChannel.ts | 16 +- src/parser/classes/CompactLink.ts | 9 +- src/parser/classes/CompactMix.ts | 9 +- src/parser/classes/CompactPlaylist.ts | 3 +- src/parser/classes/CompactStation.ts | 11 +- src/parser/classes/CompactVideo.ts | 20 +- src/parser/classes/ConfirmDialog.ts | 13 +- src/parser/classes/ContinuationItem.ts | 19 +- src/parser/classes/ConversationBar.ts | 8 +- src/parser/classes/CopyLink.ts | 12 +- src/parser/classes/CreatePlaylistDialog.ts | 17 +- src/parser/classes/DecoratedPlayerBar.ts | 10 +- src/parser/classes/DefaultPromoPanel.ts | 17 +- src/parser/classes/DidYouMean.ts | 13 +- src/parser/classes/DownloadButton.ts | 9 +- src/parser/classes/Dropdown.ts | 13 +- src/parser/classes/DropdownItem.ts | 22 +- src/parser/classes/Element.ts | 22 +- src/parser/classes/EmergencyOnebox.ts | 15 +- src/parser/classes/EmojiPickerCategory.ts | 9 +- .../classes/EmojiPickerCategoryButton.ts | 17 +- .../classes/EmojiPickerUpsellCategory.ts | 9 +- src/parser/classes/EndScreenPlaylist.ts | 9 +- src/parser/classes/EndScreenVideo.ts | 17 +- src/parser/classes/Endscreen.ts | 12 +- src/parser/classes/EndscreenElement.ts | 69 +- src/parser/classes/ExpandableMetadata.ts | 35 +- src/parser/classes/ExpandableTab.ts | 18 +- src/parser/classes/ExpandedShelfContents.ts | 16 +- src/parser/classes/FeedFilterChipBar.ts | 16 +- src/parser/classes/FeedTabbedHeader.ts | 9 +- src/parser/classes/GameCard.ts | 12 +- src/parser/classes/GameDetails.ts | 12 +- src/parser/classes/Grid.ts | 24 +- src/parser/classes/GridChannel.ts | 10 +- src/parser/classes/GridHeader.ts | 9 +- src/parser/classes/GridMix.ts | 18 +- src/parser/classes/GridMovie.ts | 24 +- src/parser/classes/GridPlaylist.ts | 14 +- src/parser/classes/GridShow.ts | 4 +- src/parser/classes/GridVideo.ts | 22 +- src/parser/classes/GuideCollapsibleEntry.ts | 4 +- .../classes/GuideCollapsibleSectionEntry.ts | 6 +- src/parser/classes/GuideEntry.ts | 1 - src/parser/classes/GuideSection.ts | 4 +- src/parser/classes/HashtagHeader.ts | 6 +- src/parser/classes/HeatMarker.ts | 9 +- src/parser/classes/Heatmap.ts | 17 +- src/parser/classes/HeroPlaylistThumbnail.ts | 10 +- src/parser/classes/HighlightsCarousel.ts | 19 +- src/parser/classes/HistorySuggestion.ts | 9 +- src/parser/classes/HorizontalCardList.ts | 20 +- src/parser/classes/HorizontalList.ts | 16 +- src/parser/classes/HorizontalMovieList.ts | 20 +- src/parser/classes/IconLink.ts | 13 +- src/parser/classes/InfoPanelContainer.ts | 10 +- src/parser/classes/InfoPanelContent.ts | 6 +- src/parser/classes/InteractiveTabbedHeader.ts | 23 +- src/parser/classes/ItemSection.ts | 19 +- src/parser/classes/ItemSectionHeader.ts | 9 +- src/parser/classes/ItemSectionTab.ts | 14 +- src/parser/classes/ItemSectionTabbedHeader.ts | 18 +- src/parser/classes/LikeButton.ts | 15 +- src/parser/classes/LiveChat.ts | 12 +- src/parser/classes/LiveChatAuthorBadge.ts | 13 +- src/parser/classes/LiveChatDialog.ts | 18 +- src/parser/classes/LiveChatHeader.ts | 14 +- src/parser/classes/LiveChatItemList.ts | 10 +- src/parser/classes/LiveChatMessageInput.ts | 16 +- src/parser/classes/LiveChatParticipant.ts | 16 +- .../classes/LiveChatParticipantsList.ts | 14 +- src/parser/classes/MacroMarkersListItem.ts | 12 +- src/parser/classes/MerchandiseItem.ts | 9 +- src/parser/classes/MerchandiseShelf.ts | 16 +- src/parser/classes/Message.ts | 13 +- src/parser/classes/MetadataBadge.ts | 18 +- src/parser/classes/MetadataRow.ts | 15 +- src/parser/classes/MetadataRowContainer.ts | 17 +- src/parser/classes/MetadataRowHeader.ts | 9 +- src/parser/classes/MetadataScreen.ts | 12 +- src/parser/classes/MicroformatData.ts | 15 +- src/parser/classes/Mix.ts | 9 +- src/parser/classes/Movie.ts | 37 +- src/parser/classes/MovingThumbnail.ts | 13 +- src/parser/classes/MultiMarkersPlayerBar.ts | 26 +- src/parser/classes/MusicCardShelf.ts | 8 +- .../classes/MusicCardShelfHeaderBasic.ts | 2 +- src/parser/classes/MusicCarouselShelf.ts | 26 +- .../classes/MusicCarouselShelfBasicHeader.ts | 38 +- src/parser/classes/MusicDescriptionShelf.ts | 13 +- src/parser/classes/MusicDetailHeader.ts | 18 +- src/parser/classes/MusicDownloadStateBadge.ts | 9 +- .../MusicEditablePlaylistDetailHeader.ts | 13 +- src/parser/classes/MusicElementHeader.ts | 13 +- src/parser/classes/MusicHeader.ts | 14 +- src/parser/classes/MusicImmersiveHeader.ts | 17 +- src/parser/classes/MusicInlineBadge.ts | 9 +- .../classes/MusicItemThumbnailOverlay.ts | 16 +- .../classes/MusicLargeCardItemCarousel.ts | 17 +- src/parser/classes/MusicNavigationButton.ts | 9 +- src/parser/classes/MusicPlayButton.ts | 21 +- src/parser/classes/MusicPlaylistShelf.ts | 18 +- src/parser/classes/MusicQueue.ts | 12 +- src/parser/classes/MusicResponsiveListItem.ts | 5 +- .../MusicResponsiveListItemFixedColumn.ts | 9 +- .../MusicResponsiveListItemFlexColumn.ts | 11 +- src/parser/classes/MusicShelf.ts | 35 +- src/parser/classes/MusicSideAlignedItem.ts | 22 +- src/parser/classes/MusicSortFilterButton.ts | 19 +- src/parser/classes/MusicThumbnail.ts | 11 +- src/parser/classes/MusicTwoRowItem.ts | 33 +- src/parser/classes/MusicVisualHeader.ts | 25 +- src/parser/classes/NavigationEndpoint.ts | 14 +- src/parser/classes/Notification.ts | 10 +- src/parser/classes/PageIntroduction.ts | 9 +- .../classes/PlayerAnnotationsExpanded.ts | 8 +- src/parser/classes/PlayerCaptionsTracklist.ts | 9 +- src/parser/classes/PlayerErrorMessage.ts | 24 +- .../classes/PlayerLegacyDesktopYpcOffer.ts | 6 +- .../classes/PlayerLegacyDesktopYpcTrailer.ts | 10 +- .../classes/PlayerLiveStoryboardSpec.ts | 6 +- src/parser/classes/PlayerMicroformat.ts | 19 +- src/parser/classes/PlayerOverlay.ts | 19 +- src/parser/classes/PlayerOverlayAutoplay.ts | 25 +- src/parser/classes/PlayerStoryboardSpec.ts | 9 +- src/parser/classes/Playlist.ts | 24 +- src/parser/classes/PlaylistCustomThumbnail.ts | 9 +- src/parser/classes/PlaylistHeader.ts | 20 +- src/parser/classes/PlaylistInfoCardContent.ts | 9 +- src/parser/classes/PlaylistMetadata.ts | 11 +- src/parser/classes/PlaylistPanel.ts | 19 +- src/parser/classes/PlaylistPanelVideo.ts | 33 +- .../classes/PlaylistPanelVideoWrapper.ts | 19 +- src/parser/classes/PlaylistSidebar.ts | 12 +- .../classes/PlaylistSidebarPrimaryInfo.ts | 19 +- .../classes/PlaylistSidebarSecondaryInfo.ts | 12 +- src/parser/classes/PlaylistVideo.ts | 23 +- src/parser/classes/PlaylistVideoList.ts | 16 +- src/parser/classes/PlaylistVideoThumbnail.ts | 9 +- src/parser/classes/Poll.ts | 21 +- src/parser/classes/Post.ts | 9 +- src/parser/classes/PostMultiImage.ts | 11 +- src/parser/classes/ProfileColumn.ts | 14 +- src/parser/classes/ProfileColumnStats.ts | 16 +- src/parser/classes/ProfileColumnStatsEntry.ts | 9 +- src/parser/classes/ProfileColumnUserInfo.ts | 9 +- src/parser/classes/RecognitionShelf.ts | 16 +- src/parser/classes/ReelItem.ts | 11 +- src/parser/classes/ReelShelf.ts | 23 +- src/parser/classes/RelatedChipCloud.ts | 14 +- src/parser/classes/RichGrid.ts | 21 +- src/parser/classes/RichItem.ts | 12 +- src/parser/classes/RichListHeader.ts | 23 +- src/parser/classes/RichMetadata.ts | 16 +- src/parser/classes/RichMetadataRow.ts | 14 +- src/parser/classes/RichSection.ts | 12 +- src/parser/classes/RichShelf.ts | 21 +- src/parser/classes/SearchBox.ts | 23 +- src/parser/classes/SearchFilter.ts | 9 +- src/parser/classes/SearchFilterGroup.ts | 11 +- src/parser/classes/SearchRefinementCard.ts | 9 +- src/parser/classes/SearchSubMenu.ts | 10 +- src/parser/classes/SearchSuggestion.ts | 20 +- .../classes/SearchSuggestionsSection.ts | 16 +- .../classes/SecondarySearchContainer.ts | 16 +- src/parser/classes/SectionList.ts | 32 +- .../classes/SegmentedLikeDislikeButton.ts | 6 +- src/parser/classes/SettingBoolean.ts | 23 +- src/parser/classes/SettingsCheckbox.ts | 9 +- src/parser/classes/SettingsOptions.ts | 24 +- src/parser/classes/SettingsSidebar.ts | 17 +- src/parser/classes/SettingsSwitch.ts | 13 +- src/parser/classes/SharedPost.ts | 9 +- src/parser/classes/Shelf.ts | 22 +- src/parser/classes/ShowCustomThumbnail.ts | 2 +- src/parser/classes/SimpleCardContent.ts | 17 +- src/parser/classes/SimpleCardTeaser.ts | 13 +- src/parser/classes/SimpleTextSection.ts | 12 +- .../classes/SingleActionEmergencySupport.ts | 9 +- .../classes/SingleColumnBrowseResults.ts | 17 +- .../SingleColumnMusicWatchNextResults.ts | 10 +- src/parser/classes/SingleHeroImage.ts | 9 +- src/parser/classes/SlimOwner.ts | 18 +- src/parser/classes/SlimVideoMetadata.ts | 14 +- src/parser/classes/SortFilterSubMenu.ts | 22 +- src/parser/classes/SubFeedOption.ts | 13 +- src/parser/classes/SubFeedSelector.ts | 17 +- src/parser/classes/SubscribeButton.ts | 16 +- .../SubscriptionNotificationToggleButton.ts | 14 +- src/parser/classes/Tab.ts | 17 +- src/parser/classes/Tabbed.ts | 15 +- src/parser/classes/TabbedSearchResults.ts | 16 +- src/parser/classes/TextHeader.ts | 9 +- .../classes/ThumbnailLandscapePortrait.ts | 9 +- .../classes/ThumbnailOverlayBottomPanel.ts | 8 +- .../classes/ThumbnailOverlayEndorsement.ts | 11 +- .../classes/ThumbnailOverlayHoverText.ts | 9 +- .../ThumbnailOverlayInlineUnplayable.ts | 11 +- .../classes/ThumbnailOverlayLoadingPreview.ts | 11 +- .../classes/ThumbnailOverlayNowPlaying.ts | 11 +- src/parser/classes/ThumbnailOverlayPinking.ts | 9 +- .../classes/ThumbnailOverlayPlaybackStatus.ts | 15 +- .../classes/ThumbnailOverlayResumePlayback.ts | 9 +- .../classes/ThumbnailOverlaySidePanel.ts | 9 +- .../classes/ThumbnailOverlayTimeStatus.ts | 9 +- .../classes/ThumbnailOverlayToggleButton.ts | 15 +- src/parser/classes/TimedMarkerDecoration.ts | 11 +- .../classes/TitleAndButtonListHeader.ts | 9 +- src/parser/classes/ToggleButton.ts | 29 +- src/parser/classes/Tooltip.ts | 12 +- src/parser/classes/TopicChannelDetails.ts | 18 +- src/parser/classes/TwoColumnBrowseResults.ts | 16 +- src/parser/classes/TwoColumnSearchResults.ts | 16 +- .../classes/TwoColumnWatchNextResults.ts | 28 +- src/parser/classes/UniversalWatchCard.ts | 21 +- src/parser/classes/UpsellDialog.ts | 10 +- src/parser/classes/VerticalList.ts | 16 +- src/parser/classes/VerticalWatchCardList.ts | 21 +- src/parser/classes/Video.ts | 86 +-- src/parser/classes/VideoCard.ts | 9 +- src/parser/classes/VideoInfoCardContent.ts | 13 +- src/parser/classes/VideoOwner.ts | 11 +- src/parser/classes/VideoPrimaryInfo.ts | 18 +- src/parser/classes/VideoSecondaryInfo.ts | 10 +- src/parser/classes/WatchCardCompactVideo.ts | 13 +- src/parser/classes/WatchCardHeroVideo.ts | 16 +- src/parser/classes/WatchCardRichHeader.ts | 15 +- .../classes/WatchCardSectionSequence.ts | 14 +- src/parser/classes/WatchNextEndScreen.ts | 18 +- src/parser/classes/WatchNextTabbedResults.ts | 9 +- src/parser/classes/YpcTrailer.ts | 10 +- .../actions/AppendContinuationItemsAction.ts | 10 +- src/parser/classes/actions/OpenPopupAction.ts | 10 +- .../analytics/AnalyticsMainAppKeyMetrics.ts | 14 +- src/parser/classes/analytics/AnalyticsRoot.ts | 6 +- .../analytics/AnalyticsShortsCarouselCard.ts | 8 +- .../classes/analytics/AnalyticsVideo.ts | 6 +- .../analytics/AnalyticsVodCarouselCard.ts | 14 +- .../classes/analytics/CtaGoToCreatorStudio.ts | 7 +- .../classes/analytics/DataModelSection.ts | 6 +- src/parser/classes/analytics/StatRow.ts | 7 +- .../classes/comments/AuthorCommentBadge.ts | 13 +- src/parser/classes/comments/Comment.ts | 27 +- .../classes/comments/CommentActionButtons.ts | 15 +- src/parser/classes/comments/CommentDialog.ts | 11 +- src/parser/classes/comments/CommentReplies.ts | 14 +- .../classes/comments/CommentReplyDialog.ts | 11 +- .../classes/comments/CommentSimplebox.ts | 17 +- src/parser/classes/comments/CommentThread.ts | 24 +- .../comments/CommentsEntryPointHeader.ts | 24 +- .../comments/CommentsEntryPointTeaser.ts | 23 + src/parser/classes/comments/CommentsHeader.ts | 31 +- src/parser/classes/comments/CreatorHeart.ts | 17 +- src/parser/classes/comments/EmojiPicker.ts | 16 +- src/parser/classes/comments/PdgCommentChip.ts | 17 +- .../classes/comments/SponsorCommentBadge.ts | 6 +- .../livechat/AddBannerToLiveChatCommand.ts | 10 +- .../classes/livechat/AddChatItemAction.ts | 14 +- .../livechat/AddLiveChatTickerItemAction.ts | 10 +- .../classes/livechat/DimChatItemAction.ts | 7 +- .../classes/livechat/LiveChatActionPanel.ts | 11 +- .../livechat/MarkChatItemAsDeletedAction.ts | 7 +- .../MarkChatItemsByAuthorAsDeletedAction.ts | 11 +- .../RemoveBannerForLiveChatCommand.ts | 7 +- .../classes/livechat/RemoveChatItemAction.ts | 7 +- .../livechat/RemoveChatItemByAuthorAction.ts | 7 +- .../classes/livechat/ReplaceChatItemAction.ts | 9 +- .../classes/livechat/ReplayChatItemAction.ts | 16 +- .../livechat/ShowLiveChatActionPanelAction.ts | 11 +- .../livechat/ShowLiveChatDialogAction.ts | 9 +- .../livechat/ShowLiveChatTooltipCommand.ts | 9 +- .../classes/livechat/UpdateDateTextAction.ts | 7 +- .../livechat/UpdateDescriptionAction.ts | 7 +- .../livechat/UpdateLiveChatPollAction.ts | 9 +- .../classes/livechat/UpdateTitleAction.ts | 7 +- .../livechat/UpdateViewershipAction.ts | 7 +- .../livechat/items/LiveChatAutoModMessage.ts | 18 +- .../classes/livechat/items/LiveChatBanner.ts | 10 +- .../livechat/items/LiveChatBannerHeader.ts | 20 +- .../livechat/items/LiveChatBannerPoll.ts | 19 +- .../livechat/items/LiveChatMembershipItem.ts | 15 +- .../livechat/items/LiveChatPaidMessage.ts | 19 +- .../livechat/items/LiveChatPaidSticker.ts | 23 +- .../livechat/items/LiveChatPlaceholderItem.ts | 6 +- .../livechat/items/LiveChatProductItem.ts | 11 +- .../items/LiveChatRestrictedParticipation.ts | 12 +- .../livechat/items/LiveChatTextMessage.ts | 26 +- .../items/LiveChatTickerPaidMessageItem.ts | 25 +- .../items/LiveChatTickerPaidStickerItem.ts | 6 +- .../items/LiveChatTickerSponsorItem.ts | 20 +- .../items/LiveChatViewerEngagementMessage.ts | 16 +- .../classes/livechat/items/PollHeader.ts | 17 +- src/parser/classes/menus/Menu.ts | 20 +- .../classes/menus/MenuNavigationItem.ts | 6 +- src/parser/classes/menus/MenuServiceItem.ts | 7 +- .../classes/menus/MenuServiceItemDownload.ts | 11 +- src/parser/classes/menus/MultiPageMenu.ts | 15 +- .../menus/MultiPageMenuNotificationSection.ts | 12 +- .../classes/menus/MusicMenuItemDivider.ts | 10 +- .../classes/menus/MusicMultiSelectMenu.ts | 25 +- .../classes/menus/MusicMultiSelectMenuItem.ts | 27 +- src/parser/classes/menus/SimpleMenuHeader.ts | 14 +- src/parser/classes/misc/Author.ts | 42 +- src/parser/classes/misc/ChildElement.ts | 21 +- src/parser/classes/misc/EmojiRun.ts | 12 +- src/parser/classes/misc/Format.ts | 58 +- src/parser/classes/misc/Text.ts | 30 +- src/parser/classes/misc/TextRun.ts | 18 +- src/parser/classes/misc/Thumbnail.ts | 6 +- src/parser/classes/misc/VideoDetails.ts | 6 +- src/parser/classes/ytkids/AnchoredSection.ts | 12 +- .../classes/ytkids/KidsCategoriesHeader.ts | 10 +- src/parser/classes/ytkids/KidsCategoryTab.ts | 6 +- src/parser/classes/ytkids/KidsHomeScreen.ts | 10 +- src/parser/nodes.ts | 1 + src/parser/parser.ts | 8 +- src/parser/youtube/VideoInfo.ts | 2 +- src/parser/youtube/index.ts | 2 + src/utils/FormatUtils.ts | 2 +- test/constants.ts | 49 -- test/main.test.ts | 604 ++++++++++-------- 358 files changed, 2823 insertions(+), 3126 deletions(-) create mode 100644 src/parser/classes/comments/CommentsEntryPointTeaser.ts delete mode 100644 test/constants.ts diff --git a/src/core/Music.ts b/src/core/Music.ts index 629140a7..41a50b67 100644 --- a/src/core/Music.ts +++ b/src/core/Music.ts @@ -20,7 +20,6 @@ import SearchSuggestionsSection from '../parser/classes/SearchSuggestionsSection import SectionList from '../parser/classes/SectionList.js'; import Tab from '../parser/classes/Tab.js'; -import { observe } from '../parser/helpers.js'; import Proto from '../proto/index.js'; import { generateRandomString, InnertubeError, throwIfMissing } from '../utils/Utils.js'; @@ -327,7 +326,7 @@ class Music { throw new InnertubeError('Unexpected response', page); if (page.contents.item().key('type').string() === 'Message') - throw new InnertubeError(page.contents.item().as(Message).text, video_id); + throw new InnertubeError(page.contents.item().as(Message).text.toString(), video_id); const section_list = page.contents.item().as(SectionList).contents; @@ -357,12 +356,12 @@ class Music { client: 'YTMUSIC' }); - const search_suggestions_section = response.contents_memo?.getType(SearchSuggestionsSection)?.[0]; + if (!response.contents_memo) + throw new InnertubeError('Unexpected response', response); - if (!search_suggestions_section?.contents.is_array) - return observe([] as YTNode[]); + const search_suggestions_section = response.contents_memo.getType(SearchSuggestionsSection).first(); - return search_suggestions_section?.contents.array(); + return search_suggestions_section.contents; } } diff --git a/src/parser/classes/AccountChannel.ts b/src/parser/classes/AccountChannel.ts index 6c3af847..50dc2695 100644 --- a/src/parser/classes/AccountChannel.ts +++ b/src/parser/classes/AccountChannel.ts @@ -3,7 +3,7 @@ import NavigationEndpoint from './NavigationEndpoint.js'; import { YTNode } from '../helpers.js'; import type { RawNode } from '../index.js'; -class AccountChannel extends YTNode { +export default class AccountChannel extends YTNode { static type = 'AccountChannel'; title: Text; @@ -14,6 +14,4 @@ class AccountChannel extends YTNode { this.title = new Text(data.title); this.endpoint = new NavigationEndpoint(data.navigationEndpoint); } -} - -export default AccountChannel; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/AccountItemSection.ts b/src/parser/classes/AccountItemSection.ts index eb64f8da..c614df6c 100644 --- a/src/parser/classes/AccountItemSection.ts +++ b/src/parser/classes/AccountItemSection.ts @@ -1,14 +1,16 @@ import Parser from '../index.js'; - +import AccountItemSectionHeader from './AccountItemSectionHeader.js'; +import NavigationEndpoint from './NavigationEndpoint.js'; import Text from './misc/Text.js'; import Thumbnail from './misc/Thumbnail.js'; -import NavigationEndpoint from './NavigationEndpoint.js'; -import AccountItemSectionHeader from './AccountItemSectionHeader.js'; -import { YTNode } from '../helpers.js'; +import { YTNode, observe, type ObservedArray } from '../helpers.js'; import type { RawNode } from '../index.js'; -class AccountItem { +/** + * Not a real renderer but we treat it as one to keep things organized. + */ +export class AccountItem extends YTNode { static type = 'AccountItem'; account_name: Text; @@ -20,27 +22,26 @@ class AccountItem { account_byline: Text; constructor(data: RawNode) { + super(); this.account_name = new Text(data.accountName); this.account_photo = Thumbnail.fromResponse(data.accountPhoto); - this.is_selected = data.isSelected; - this.is_disabled = data.isDisabled; - this.has_channel = data.hasChannel; + this.is_selected = !!data.isSelected; + this.is_disabled = !!data.isDisabled; + this.has_channel = !!data.hasChannel; this.endpoint = new NavigationEndpoint(data.serviceEndpoint); this.account_byline = new Text(data.accountByline); } } -class AccountItemSection extends YTNode { +export default class AccountItemSection extends YTNode { static type = 'AccountItemSection'; - contents; - header; + contents: ObservedArray; + header: AccountItemSectionHeader | null; constructor(data: RawNode) { super(); - this.contents = data.contents.map((ac: any) => new AccountItem(ac.accountItem)); + this.contents = observe(data.contents.map((ac: RawNode) => new AccountItem(ac.accountItem))); this.header = Parser.parseItem(data.header, AccountItemSectionHeader); } -} - -export default AccountItemSection; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/AccountItemSectionHeader.ts b/src/parser/classes/AccountItemSectionHeader.ts index 1653392a..7e6fa325 100644 --- a/src/parser/classes/AccountItemSectionHeader.ts +++ b/src/parser/classes/AccountItemSectionHeader.ts @@ -1,7 +1,8 @@ import Text from './misc/Text.js'; import { YTNode } from '../helpers.js'; import type { RawNode } from '../index.js'; -class AccountItemSectionHeader extends YTNode { + +export default class AccountItemSectionHeader extends YTNode { static type = 'AccountItemSectionHeader'; title: Text; @@ -10,6 +11,4 @@ class AccountItemSectionHeader extends YTNode { super(); this.title = new Text(data.title); } -} - -export default AccountItemSectionHeader; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/AccountSectionList.ts b/src/parser/classes/AccountSectionList.ts index 2c5759d7..b42c8211 100644 --- a/src/parser/classes/AccountSectionList.ts +++ b/src/parser/classes/AccountSectionList.ts @@ -4,7 +4,8 @@ import AccountItemSection from './AccountItemSection.js'; import { YTNode } from '../helpers.js'; import type { RawNode } from '../index.js'; -class AccountSectionList extends YTNode { + +export default class AccountSectionList extends YTNode { static type = 'AccountSectionList'; contents; @@ -15,6 +16,4 @@ class AccountSectionList extends YTNode { this.contents = Parser.parseItem(data.contents[0], AccountItemSection); this.footers = Parser.parseItem(data.footers[0], AccountChannel); } -} - -export default AccountSectionList; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/Alert.ts b/src/parser/classes/Alert.ts index e080d24c..cd1d8e99 100644 --- a/src/parser/classes/Alert.ts +++ b/src/parser/classes/Alert.ts @@ -1,7 +1,8 @@ import Text from './misc/Text.js'; import { YTNode } from '../helpers.js'; import type { RawNode } from '../index.js'; -class Alert extends YTNode { + +export default class Alert extends YTNode { static type = 'Alert'; text: Text; @@ -12,6 +13,4 @@ class Alert extends YTNode { this.text = new Text(data.text); this.alert_type = data.type; } -} - -export default Alert; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/AudioOnlyPlayability.ts b/src/parser/classes/AudioOnlyPlayability.ts index f5f6daaa..1ccea68e 100644 --- a/src/parser/classes/AudioOnlyPlayability.ts +++ b/src/parser/classes/AudioOnlyPlayability.ts @@ -1,6 +1,7 @@ import { YTNode } from '../helpers.js'; import type { RawNode } from '../index.js'; -class AudioOnlyPlayability extends YTNode { + +export default class AudioOnlyPlayability extends YTNode { static type = 'AudioOnlyPlayability'; audio_only_availability: string; @@ -9,6 +10,4 @@ class AudioOnlyPlayability extends YTNode { super(); this.audio_only_availability = data.audioOnlyAvailability; } -} - -export default AudioOnlyPlayability; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/AutomixPreviewVideo.ts b/src/parser/classes/AutomixPreviewVideo.ts index 0759f3fa..a47d4008 100644 --- a/src/parser/classes/AutomixPreviewVideo.ts +++ b/src/parser/classes/AutomixPreviewVideo.ts @@ -1,7 +1,8 @@ import { YTNode } from '../helpers.js'; import NavigationEndpoint from './NavigationEndpoint.js'; import type { RawNode } from '../index.js'; -class AutomixPreviewVideo extends YTNode { + +export default class AutomixPreviewVideo extends YTNode { static type = 'AutomixPreviewVideo'; playlist_video?: { endpoint: NavigationEndpoint }; @@ -14,6 +15,4 @@ class AutomixPreviewVideo extends YTNode { }; } } -} - -export default AutomixPreviewVideo; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/BackstageImage.ts b/src/parser/classes/BackstageImage.ts index af11137e..bbb54a5a 100644 --- a/src/parser/classes/BackstageImage.ts +++ b/src/parser/classes/BackstageImage.ts @@ -1,18 +1,17 @@ import Thumbnail from './misc/Thumbnail.js'; import NavigationEndpoint from './NavigationEndpoint.js'; import { YTNode } from '../helpers.js'; +import type { RawNode } from '../index.js'; -class BackstageImage extends YTNode { +export default class BackstageImage extends YTNode { static type = 'BackstageImage'; image: Thumbnail[]; endpoint: NavigationEndpoint; - constructor(data: any) { + constructor(data: RawNode) { super(); this.image = Thumbnail.fromResponse(data.image); this.endpoint = new NavigationEndpoint(data.command); } -} - -export default BackstageImage; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/BackstagePost.ts b/src/parser/classes/BackstagePost.ts index 0ccd3518..e556e59c 100644 --- a/src/parser/classes/BackstagePost.ts +++ b/src/parser/classes/BackstagePost.ts @@ -1,13 +1,12 @@ -import Parser from '../index.js'; -import Author from './misc/Author.js'; -import Text from './misc/Text.js'; +import { YTNode } from '../helpers.js'; +import Parser, { type RawNode } from '../index.js'; import NavigationEndpoint from './NavigationEndpoint.js'; import CommentActionButtons from './comments/CommentActionButtons.js'; import Menu from './menus/Menu.js'; +import Author from './misc/Author.js'; +import Text from './misc/Text.js'; -import { YTNode } from '../helpers.js'; - -class BackstagePost extends YTNode { +export default class BackstagePost extends YTNode { static type = 'BackstagePost'; id: string; @@ -18,13 +17,13 @@ class BackstagePost extends YTNode { vote_status?: string; vote_count?: Text; menu?: Menu | null; - action_buttons; - vote_button; + action_buttons?: CommentActionButtons | null; + vote_button?: CommentActionButtons | null; surface: string; endpoint?: NavigationEndpoint; attachment; - constructor(data: any) { + constructor(data: RawNode) { super(); this.id = data.postId; @@ -36,40 +35,38 @@ class BackstagePost extends YTNode { this.content = new Text(data.contentText); this.published = new Text(data.publishedTimeText); - if (data.pollStatus) { + if (Reflect.has(data, 'pollStatus')) { this.poll_status = data.pollStatus; } - if (data.voteStatus) { + if (Reflect.has(data, 'voteStatus')) { this.vote_status = data.voteStatus; } - if (data.voteCount) { + if (Reflect.has(data, 'voteCount')) { this.vote_count = new Text(data.voteCount); } - if (data.actionMenu) { + if (Reflect.has(data, 'actionMenu')) { this.menu = Parser.parseItem(data.actionMenu, Menu); } - if (data.actionButtons) { + if (Reflect.has(data, 'actionButtons')) { this.action_buttons = Parser.parseItem(data.actionButtons, CommentActionButtons); } - if (data.voteButton) { + if (Reflect.has(data, 'voteButton')) { this.vote_button = Parser.parseItem(data.voteButton, CommentActionButtons); } - if (data.navigationEndpoint) { + if (Reflect.has(data, 'navigationEndpoint')) { this.endpoint = new NavigationEndpoint(data.navigationEndpoint); } - if (data.backstageAttachment) { + if (Reflect.has(data, 'backstageAttachment')) { this.attachment = Parser.parseItem(data.backstageAttachment); } this.surface = data.surface; } -} - -export default BackstagePost; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/BackstagePostThread.ts b/src/parser/classes/BackstagePostThread.ts index 77e17a19..189ceb1c 100644 --- a/src/parser/classes/BackstagePostThread.ts +++ b/src/parser/classes/BackstagePostThread.ts @@ -1,15 +1,13 @@ -import Parser from '../index.js'; +import Parser, { type RawNode } from '../index.js'; import { YTNode } from '../helpers.js'; -class BackstagePostThread extends YTNode { +export default class BackstagePostThread extends YTNode { static type = 'BackstagePostThread'; - post; + post: YTNode; - constructor(data: any) { + constructor(data: RawNode) { super(); this.post = Parser.parseItem(data.post); } -} - -export default BackstagePostThread; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/BrowseFeedActions.ts b/src/parser/classes/BrowseFeedActions.ts index b9e47eb0..432222e9 100644 --- a/src/parser/classes/BrowseFeedActions.ts +++ b/src/parser/classes/BrowseFeedActions.ts @@ -1,15 +1,13 @@ -import Parser from '../index.js'; -import { YTNode } from '../helpers.js'; +import Parser, { type RawNode } from '../index.js'; +import { type ObservedArray, YTNode } from '../helpers.js'; -class BrowseFeedActions extends YTNode { +export default class BrowseFeedActions extends YTNode { static type = 'BrowseFeedActions'; - contents; + contents: ObservedArray; - constructor(data: any) { + constructor(data: RawNode) { super(); this.contents = Parser.parseArray(data.contents); } -} - -export default BrowseFeedActions; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/BrowserMediaSession.ts b/src/parser/classes/BrowserMediaSession.ts index f62fd2ed..23f2a2c0 100644 --- a/src/parser/classes/BrowserMediaSession.ts +++ b/src/parser/classes/BrowserMediaSession.ts @@ -1,18 +1,17 @@ import Text from './misc/Text.js'; import Thumbnail from './misc/Thumbnail.js'; import { YTNode } from '../helpers.js'; +import type { RawNode } from '../index.js'; -class BrowserMediaSession extends YTNode { +export default class BrowserMediaSession extends YTNode { static type = 'BrowserMediaSession'; - album; - thumbnails; + album: Text; + thumbnails: Thumbnail[]; - constructor (data: any) { + constructor (data: RawNode) { super(); this.album = new Text(data.album); this.thumbnails = Thumbnail.fromResponse(data.thumbnailDetails); } -} - -export default BrowserMediaSession; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/Button.ts b/src/parser/classes/Button.ts index 6971e080..3d83207a 100644 --- a/src/parser/classes/Button.ts +++ b/src/parser/classes/Button.ts @@ -1,6 +1,5 @@ import Text from './misc/Text.js'; import NavigationEndpoint from './NavigationEndpoint.js'; - import { YTNode } from '../helpers.js'; import type { RawNode } from '../index.js'; @@ -8,31 +7,29 @@ export default class Button extends YTNode { static type = 'Button'; text?: string; - label?: string; tooltip?: string; icon_type?: string; is_disabled?: boolean; - endpoint: NavigationEndpoint; constructor(data: RawNode) { super(); - if (data.text) { + if (Reflect.has(data, 'text')) { this.text = new Text(data.text).toString(); } - if (data.accessibility?.label) { - this.label = data.accessibility?.label; + if (Reflect.has(data, 'accessibility') && Reflect.has(data.accessibility, 'label')) { + this.label = data.accessibility.label; } - if (data.tooltip) { + if (Reflect.has(data, 'tooltip')) { this.tooltip = data.tooltip; } - if (data.icon?.iconType) { - this.icon_type = data.icon?.iconType; + if (Reflect.has(data, 'icon') && Reflect.has(data.icon, 'iconType')) { + this.icon_type = data.icon.iconType; } if (Reflect.has(data, 'isDisabled')) { diff --git a/src/parser/classes/C4TabbedHeader.ts b/src/parser/classes/C4TabbedHeader.ts index 2c6c5be4..305cd4ed 100644 --- a/src/parser/classes/C4TabbedHeader.ts +++ b/src/parser/classes/C4TabbedHeader.ts @@ -1,15 +1,13 @@ -import Parser from '../index.js'; +import { YTNode } from '../helpers.js'; +import Parser, { type RawNode } from '../index.js'; +import Button from './Button.js'; +import ChannelHeaderLinks from './ChannelHeaderLinks.js'; +import SubscribeButton from './SubscribeButton.js'; import Author from './misc/Author.js'; import Text from './misc/Text.js'; import Thumbnail from './misc/Thumbnail.js'; -import Button from './Button.js'; -import ChannelHeaderLinks from './ChannelHeaderLinks.js'; -import SubscribeButton from './SubscribeButton.js'; - -import { YTNode } from '../helpers.js'; - -class C4TabbedHeader extends YTNode { +export default class C4TabbedHeader extends YTNode { static type = 'C4TabbedHeader'; author: Author; @@ -24,53 +22,51 @@ class C4TabbedHeader extends YTNode { channel_handle?: Text; channel_id?: string; - constructor(data: any) { + constructor(data: RawNode) { super(); this.author = new Author({ simpleText: data.title, navigationEndpoint: data.navigationEndpoint }, data.badges, data.avatar); - if (data.banner) { + if (Reflect.has(data, 'banner')) { this.banner = Thumbnail.fromResponse(data.banner); } - if (data.tv_banner) { + if (Reflect.has(data, 'tv_banner')) { this.tv_banner = Thumbnail.fromResponse(data.tvBanner); } - if (data.mobile_banner) { + if (Reflect.has(data, 'mobile_banner')) { this.mobile_banner = Thumbnail.fromResponse(data.mobileBanner); } - if (data.subscriberCountText) { + if (Reflect.has(data, 'subscriberCountText')) { this.subscribers = new Text(data.subscriberCountText); } - if (data.videosCountText) { + if (Reflect.has(data, 'videosCountText')) { this.videos_count = new Text(data.videosCountText); } - if (data.sponsorButton) { + if (Reflect.has(data, 'sponsorButton')) { this.sponsor_button = Parser.parseItem(data.sponsorButton, Button); } - if (data.subscribeButton) { + if (Reflect.has(data, 'subscribeButton')) { this.subscribe_button = Parser.parseItem(data.subscribeButton, [ SubscribeButton, Button ]); } - if (data.headerLinks) { + if (Reflect.has(data, 'headerLinks')) { this.header_links = Parser.parseItem(data.headerLinks, ChannelHeaderLinks); } - if (data.channelHandleText) { + if (Reflect.has(data, 'channelHandleText')) { this.channel_handle = new Text(data.channelHandleText); } - if (data.channelId) { + if (Reflect.has(data, 'channelId')) { this.channel_id = data.channelId; } } -} - -export default C4TabbedHeader; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/CallToActionButton.ts b/src/parser/classes/CallToActionButton.ts index a803b5ef..106f9aed 100644 --- a/src/parser/classes/CallToActionButton.ts +++ b/src/parser/classes/CallToActionButton.ts @@ -1,19 +1,18 @@ import Text from './misc/Text.js'; import { YTNode } from '../helpers.js'; +import type { RawNode } from '../index.js'; -class CallToActionButton extends YTNode { +export default class CallToActionButton extends YTNode { static type = 'CallToActionButton'; label: Text; icon_type: string; style: string; - constructor(data: any) { + constructor(data: RawNode) { super(); this.label = new Text(data.label); this.icon_type = data.icon.iconType; this.style = data.style; } -} - -export default CallToActionButton; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/Card.ts b/src/parser/classes/Card.ts index 872476d5..f49dc03c 100644 --- a/src/parser/classes/Card.ts +++ b/src/parser/classes/Card.ts @@ -1,13 +1,13 @@ -import Parser from '../index.js'; +import Parser, { type RawNode } from '../index.js'; import { YTNode } from '../helpers.js'; -class Card extends YTNode { +export default class Card extends YTNode { static type = 'Card'; - teaser; - content; - card_id: string | null; - feature: string | null; + teaser: YTNode; + content: YTNode; + card_id?: string; + feature?: string; cue_ranges: { start_card_active_ms: string; @@ -16,12 +16,18 @@ class Card extends YTNode { icon_after_teaser_ms: string; }[]; - constructor(data: any) { + constructor(data: RawNode) { super(); this.teaser = Parser.parseItem(data.teaser); this.content = Parser.parseItem(data.content); - this.card_id = data.cardId || null; - this.feature = data.feature || null; + + if (Reflect.has(data, 'cardId')) { + this.card_id = data.cardId; + } + + if (Reflect.has(data, 'feature')) { + this.feature = data.feature; + } this.cue_ranges = data.cueRanges.map((cr: any) => ({ start_card_active_ms: cr.startCardActiveMs, @@ -30,6 +36,4 @@ class Card extends YTNode { icon_after_teaser_ms: cr.iconAfterTeaserMs })); } -} - -export default Card; +} \ No newline at end of file diff --git a/src/parser/classes/CardCollection.ts b/src/parser/classes/CardCollection.ts index 5f60d81d..ba57812a 100644 --- a/src/parser/classes/CardCollection.ts +++ b/src/parser/classes/CardCollection.ts @@ -1,20 +1,18 @@ -import Parser from '../index.js'; +import { YTNode, type ObservedArray } from '../helpers.js'; +import Parser, { type RawNode } from '../index.js'; import Text from './misc/Text.js'; -import { YTNode } from '../helpers.js'; -class CardCollection extends YTNode { +export default class CardCollection extends YTNode { static type = 'CardCollection'; - cards; + cards: ObservedArray; header: Text; allow_teaser_dismiss: boolean; - constructor(data: any) { + constructor(data: RawNode) { super(); this.cards = Parser.parseArray(data.cards); this.header = new Text(data.headerText); this.allow_teaser_dismiss = data.allowTeaserDismiss; } -} - -export default CardCollection; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/CarouselHeader.ts b/src/parser/classes/CarouselHeader.ts index fb3cde85..d3e617b1 100644 --- a/src/parser/classes/CarouselHeader.ts +++ b/src/parser/classes/CarouselHeader.ts @@ -1,15 +1,13 @@ -import Parser from '../index.js'; -import { YTNode } from '../helpers.js'; +import Parser, { type RawNode } from '../index.js'; +import { type ObservedArray, YTNode } from '../helpers.js'; -class CarouselHeader extends YTNode { +export default class CarouselHeader extends YTNode { static type = 'CarouselHeader'; - contents: YTNode[]; + contents: ObservedArray; - constructor(data: any) { + constructor(data: RawNode) { super(); this.contents = Parser.parseArray(data.contents); } -} - -export default CarouselHeader; \ No newline at end of file +} \ No newline at end of file diff --git a/src/parser/classes/CarouselItem.ts b/src/parser/classes/CarouselItem.ts index 58810e79..871711a1 100644 --- a/src/parser/classes/CarouselItem.ts +++ b/src/parser/classes/CarouselItem.ts @@ -1,18 +1,17 @@ -import Parser from '../index.js'; -import { YTNode } from '../helpers.js'; - +import Parser, { type RawNode } from '../index.js'; +import { type ObservedArray, YTNode } from '../helpers.js'; import Thumbnail from './misc/Thumbnail.js'; -class CarouselItem extends YTNode { +export default class CarouselItem extends YTNode { static type = 'CarouselItem'; - items: YTNode[]; + items: ObservedArray; background_color: string; layout_style: string; pagination_thumbnails: Thumbnail[]; paginator_alignment: string; - constructor (data: any) { + constructor (data: RawNode) { super(); this.items = Parser.parseArray(data.carouselItems); this.background_color = data.backgroundColor; @@ -20,6 +19,9 @@ class CarouselItem extends YTNode { this.pagination_thumbnails = Thumbnail.fromResponse(data.paginationThumbnails); this.paginator_alignment = data.paginatorAlignment; } -} -export default CarouselItem; \ No newline at end of file + // XXX: For consistency. + get contents() { + return this.items; + } +} \ No newline at end of file diff --git a/src/parser/classes/Channel.ts b/src/parser/classes/Channel.ts index 5ce7ee58..1c08d869 100644 --- a/src/parser/classes/Channel.ts +++ b/src/parser/classes/Channel.ts @@ -1,28 +1,25 @@ -import Parser from '../index.js'; - -import Text from './misc/Text.js'; -import Author from './misc/Author.js'; -import NavigationEndpoint from './NavigationEndpoint.js'; - -import SubscribeButton from './SubscribeButton.js'; -import Button from './Button.js'; - import { YTNode } from '../helpers.js'; +import Parser, { type RawNode } from '../index.js'; +import Button from './Button.js'; +import NavigationEndpoint from './NavigationEndpoint.js'; +import SubscribeButton from './SubscribeButton.js'; +import Author from './misc/Author.js'; +import Text from './misc/Text.js'; -class Channel extends YTNode { +export default class Channel extends YTNode { static type = 'Channel'; id: string; author: Author; - subscribers: Text; - videos: Text; + subscriber_count: Text; + video_count: Text; long_byline: Text; short_byline: Text; endpoint: NavigationEndpoint; subscribe_button: SubscribeButton | Button | null; description_snippet: Text; - constructor(data: any) { + constructor(data: RawNode) { super(); this.id = data.channelId; @@ -31,15 +28,31 @@ class Channel extends YTNode { navigationEndpoint: data.navigationEndpoint }, data.ownerBadges, data.thumbnail); - // TODO: subscriberCountText is now the channel's handle and videoCountText is the subscriber count. Why haven't they renamed the properties? - this.subscribers = new Text(data.subscriberCountText); - this.videos = new Text(data.videoCountText); + // XXX: `subscriberCountText` is now the channel's handle and `videoCountText` is the subscriber count. + this.subscriber_count = new Text(data.subscriberCountText); + this.video_count = new Text(data.videoCountText); this.long_byline = new Text(data.longBylineText); this.short_byline = new Text(data.shortBylineText); this.endpoint = new NavigationEndpoint(data.navigationEndpoint); this.subscribe_button = Parser.parseItem(data.subscribeButton, [ SubscribeButton, Button ]); this.description_snippet = new Text(data.descriptionSnippet); } -} -export default Channel; + /** + * @deprecated + * This will be removed in a future release. + * Please use {@link Channel.subscriber_count} instead. + */ + get subscribers(): Text { + return this.subscriber_count; + } + + /** + * @deprecated + * This will be removed in a future release. + * Please use {@link Channel.video_count} instead. + */ + get videos(): Text { + return this.video_count; + } +} \ No newline at end of file diff --git a/src/parser/classes/ChannelAboutFullMetadata.ts b/src/parser/classes/ChannelAboutFullMetadata.ts index d6ef6687..c6de7523 100644 --- a/src/parser/classes/ChannelAboutFullMetadata.ts +++ b/src/parser/classes/ChannelAboutFullMetadata.ts @@ -1,14 +1,11 @@ -import Parser from '../index.js'; - +import { YTNode, type ObservedArray } from '../helpers.js'; +import Parser, { type RawNode } from '../index.js'; +import Button from './Button.js'; +import NavigationEndpoint from './NavigationEndpoint.js'; import Text from './misc/Text.js'; import Thumbnail from './misc/Thumbnail.js'; -import NavigationEndpoint from './NavigationEndpoint.js'; -import Button from './Button.js'; - -import { YTNode } from '../helpers.js'; - -class ChannelAboutFullMetadata extends YTNode { +export default class ChannelAboutFullMetadata extends YTNode { static type = 'ChannelAboutFullMetadata'; id: string; @@ -22,15 +19,15 @@ class ChannelAboutFullMetadata extends YTNode { title: Text; }[]; - views: Text; - joined: Text; + view_count: Text; + joined_date: Text; description: Text; email_reveal: NavigationEndpoint; can_reveal_email: boolean; country: Text; - buttons: Button[]; + buttons: ObservedArray