diff --git a/src/parser/youtube/Channel.ts b/src/parser/youtube/Channel.ts index ffbf36e3..2748d072 100644 --- a/src/parser/youtube/Channel.ts +++ b/src/parser/youtube/Channel.ts @@ -23,9 +23,15 @@ import SortFilterSubMenu from '../classes/SortFilterSubMenu.js'; import ContinuationItem from '../classes/ContinuationItem.js'; import NavigationEndpoint from '../classes/NavigationEndpoint.js'; -import type { AppendContinuationItemsAction, ReloadContinuationItemsCommand } from '../index.js'; +import type { + AppendContinuationItemsAction, + NavigateAction, + ReloadContinuationItemsCommand, + ShowMiniplayerCommand +} from '../index.js'; import type { ApiResponse, Actions } from '../../core/index.js'; import type { IBrowseResponse } from '../types/index.js'; +import type OpenPopupAction from '../classes/actions/OpenPopupAction.js'; export default class Channel extends TabbedFeed { public header?: C4TabbedHeader | CarouselHeader | InteractiveTabbedHeader | PageHeader; @@ -291,7 +297,7 @@ export default class Channel extends TabbedFeed { } export class ChannelListContinuation extends Feed { - contents?: ReloadContinuationItemsCommand | AppendContinuationItemsAction; + contents?: AppendContinuationItemsAction | OpenPopupAction | NavigateAction | ShowMiniplayerCommand | ReloadContinuationItemsCommand; constructor(actions: Actions, data: ApiResponse | IBrowseResponse, already_parsed = false) { super(actions, data, already_parsed); @@ -310,7 +316,7 @@ export class ChannelListContinuation extends Feed { export class FilteredChannelList extends FilterableFeed { applied_filter?: ChipCloudChip; - contents?: ReloadContinuationItemsCommand | AppendContinuationItemsAction; + contents?: AppendContinuationItemsAction | OpenPopupAction | NavigateAction | ShowMiniplayerCommand | ReloadContinuationItemsCommand; constructor(actions: Actions, data: ApiResponse | IBrowseResponse, already_parsed = false) { super(actions, data, already_parsed); diff --git a/src/parser/youtube/Comments.ts b/src/parser/youtube/Comments.ts index b8c139e0..ff1eaccd 100644 --- a/src/parser/youtube/Comments.ts +++ b/src/parser/youtube/Comments.ts @@ -7,7 +7,8 @@ import CommentsHeader from '../classes/comments/CommentsHeader.js'; import CommentSimplebox from '../classes/comments/CommentSimplebox.js'; import CommentThread from '../classes/comments/CommentThread.js'; import ContinuationItem from '../classes/ContinuationItem.js'; - +import { ReloadContinuationItemsCommand } from '../index.js'; +import AppendContinuationItemsAction from '../classes/actions/AppendContinuationItemsAction.js'; import type { Actions, ApiResponse } from '../../core/index.js'; import type { INextResponse } from '../types/index.js'; @@ -28,8 +29,8 @@ export default class Comments { if (!contents) throw new InnertubeError('Comments page did not have any content.'); - const header_node = contents.at(0); - const body_node = contents.at(1); + const header_node = contents.at(0)?.as(AppendContinuationItemsAction, ReloadContinuationItemsCommand); + const body_node = contents.at(1)?.as(AppendContinuationItemsAction, ReloadContinuationItemsCommand); this.header = header_node?.contents?.firstOfType(CommentsHeader); diff --git a/src/parser/youtube/Search.ts b/src/parser/youtube/Search.ts index 05972d24..eaace1e9 100644 --- a/src/parser/youtube/Search.ts +++ b/src/parser/youtube/Search.ts @@ -13,6 +13,8 @@ import { observe } from '../helpers.js'; import type { ApiResponse, Actions } from '../../core/index.js'; import type { ObservedArray, YTNode } from '../helpers.js'; import type { ISearchResponse } from '../types/index.js'; +import { ReloadContinuationItemsCommand } from '../index.js'; +import AppendContinuationItemsAction from '../classes/actions/AppendContinuationItemsAction.js'; export default class Search extends Feed { public header?: SearchHeader; @@ -28,7 +30,7 @@ export default class Search extends Feed { const contents = this.page.contents_memo?.getType(SectionList).first().contents || - this.page.on_response_received_commands?.first().contents; + this.page.on_response_received_commands?.first().as(AppendContinuationItemsAction, ReloadContinuationItemsCommand).contents; if (!contents) throw new InnertubeError('No contents found in search response'); diff --git a/src/parser/youtube/VideoInfo.ts b/src/parser/youtube/VideoInfo.ts index 4fa20e7f..a1d189bf 100644 --- a/src/parser/youtube/VideoInfo.ts +++ b/src/parser/youtube/VideoInfo.ts @@ -27,6 +27,9 @@ import VideoDescriptionMusicSection from '../classes/VideoDescriptionMusicSectio import LiveChatWrap from './LiveChat.js'; import type { RawNode } from '../index.js'; +import { ReloadContinuationItemsCommand } from '../index.js'; +import AppendContinuationItemsAction from '../classes/actions/AppendContinuationItemsAction.js'; + import type { Actions, ApiResponse } from '../../core/index.js'; import type { ObservedArray, YTNode } from '../helpers.js'; @@ -160,7 +163,7 @@ export default class VideoInfo extends MediaInfo { const response = await cloud_chip.endpoint?.call(this.actions, { parse: true }); const data = response?.on_response_received_endpoints?.get({ target_id: 'watch-next-feed' }); - this.watch_next_feed = data?.contents; + this.watch_next_feed = data?.as(AppendContinuationItemsAction, ReloadContinuationItemsCommand).contents; return this; } @@ -185,7 +188,7 @@ export default class VideoInfo extends MediaInfo { if (!data) throw new InnertubeError('AppendContinuationItemsAction not found'); - this.watch_next_feed = data?.contents; + this.watch_next_feed = data?.as(AppendContinuationItemsAction, ReloadContinuationItemsCommand).contents; if (this.watch_next_feed?.at(-1)?.is(ContinuationItem)) { this.#watch_next_continuation = this.watch_next_feed.pop()?.as(ContinuationItem); } else {