diff --git a/src/parser/youtube/Search.ts b/src/parser/youtube/Search.ts index a6b7bbac..54c07093 100644 --- a/src/parser/youtube/Search.ts +++ b/src/parser/youtube/Search.ts @@ -8,13 +8,15 @@ import SearchSubMenu from '../classes/SearchSubMenu.js'; import SectionList from '../classes/SectionList.js'; import UniversalWatchCard from '../classes/UniversalWatchCard.js'; +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'; export default class Search extends Feed { header?: SearchHeader; - results?: ObservedArray | null; + results: ObservedArray; refinements: string[]; estimated_results: number; sub_menu?: SearchSubMenu; @@ -34,9 +36,7 @@ export default class Search extends Feed { if (this.page.header) this.header = this.page.header.item().as(SearchHeader); - this.results = contents.find( - (content) => content.is(ItemSection) && (content.contents && content.contents.length > 0) - )?.as(ItemSection)?.contents; + this.results = observe(contents.filterType(ItemSection).flatMap((section) => section.contents)); this.refinements = this.page.refinements || []; this.estimated_results = this.page.estimated_results || 0;