DrKain / scrape-youtube

A lightning fast package to scrape YouTube search results
MIT License
108 stars 30 forks source link

youtube.search is not a function #49

Closed CameronCT closed 2 years ago

CameronCT commented 2 years ago

Describe the bug When trying to use search it returns with youtube.search is not a function.

Here is the code below

import youtube from 'scrape-youtube';
const getYouTubeDetails = await youtube.search(`${useSong.artist} - ${useSong.title}`);
console.log(getYouTubeDetails);

Returns with error:

UnhandledPromiseRejectionWarning: TypeError: youtube.search is not a function
    at Timeout._onTimeout (file:///C:/Users/ctouc/Documents/GitHub/billboard-scraper/youtube.js:25:53)
CameronCT commented 2 years ago

As a small update adjusting the code to do await youtube.default.search seems to allow this to work.

Possibly an issue with me using ESM over CJS?

DrKain commented 2 years ago

Probably. I don't remember why I used default export for this package. If you update to 2.1.10 you can use

import { youtube } from 'scrape-youtube';