Search fixed

This commit is contained in:
killer069 2021-10-03 15:19:01 +05:30
parent ca35691b63
commit 0874f716dc

View File

@ -31,7 +31,8 @@ export function ParseSearchResult(html: string, options?: ParseSearchInterface):
json_data.contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer.contents[0] json_data.contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer.contents[0]
.itemSectionRenderer.contents; .itemSectionRenderer.contents;
for (let i = 0; i < details.length; i++) { for (let i = 0; i < details.length; i++) {
if (typeof options.limit === 'number' && options.limit > 0 && results.length >= options.limit) break; if (typeof options.limit === 'number' && options.limit > 0 && results.length === options.limit) break;
if(!details[i].videoRenderer && !details[i].channelRenderer && !details[i].playlistRenderer) continue;
if (options.type === 'video') { if (options.type === 'video') {
const parsed = parseVideo(details[i]); const parsed = parseVideo(details[i]);
if (!parsed) continue; if (!parsed) continue;
@ -154,7 +155,7 @@ export function parseVideo(data?: any): YouTubeVideo {
* @returns YouTubePlaylist class * @returns YouTubePlaylist class
*/ */
export function parsePlaylist(data?: any): YouTubePlayList { export function parsePlaylist(data?: any): YouTubePlayList {
if (!data.playlistRenderer) throw new Error('Failed to Parse YouTube Playlist'); if (!data || !data.playlistRenderer) throw new Error('Failed to Parse YouTube Playlist');
const res = new YouTubePlayList( const res = new YouTubePlayList(
{ {