-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only one result in Items. #6
Comments
Hey, sorry for the late reply. By default the API fetches one item if you provide a search string. To fetch multiple results, you'd want to prefix the search with getInfo('ytsearch10:This is an example', [], true).then((info) => {
// info.items contains 10 entries
res.json(info.items);
}) This is how youtube-dl handles searches. Although depending on the use case, it would be better to fetch search results from the YouTube API directly since:
|
Also, the third argument is a boolean that defines when the promise is resolved: If set to getInfo('ytsearch10:This is an example', [], true).then((info) => {
console.log(info.items);
}) If set to getInfo('ytsearch10:This is an example').then(info => {
if (info.partial) {
info.on('video', v => console.log(v.title))
info.on('done', () => console.log(info.items)
}
}) |
Ah, thank you so much for this explanation! Problem only is, the project I'm working with requires the user itself to do the api calls. I will make that as an option, IF they insert their own API key, but for the ones that do not want that I will have a look in what you all gave me, and maybe you can also add this to your project as explanation 😄 |
Dear developer!
I'm not sure if I'm doing something wrong here, but I think I'm doing everything according to the documentation.
But when I use
It only gives me an array with only one item, I tried it with different searched that I was certain of that it would give me more results when I search it on YouTube itself.
Maybe something is up with the API, or was it by intention that you only get one result?
Sincerely Ashley
The text was updated successfully, but these errors were encountered: