paulomcnally / youtube-node

Youtube api implementation for nodeJS
https://www.npmjs.com/package/youtube-node
Apache License 2.0
108 stars 53 forks source link

addParam('type', 'video') doesn't filter out all videos #41

Open JWOverschot opened 6 years ago

JWOverschot commented 6 years ago

on https://developers.google.com/youtube/v3/docs/search/list
type video is valid. But it doesn't work, it still returns channels instead of only videos.

youTube.addParam('type', 'video')

Any idea what it could be?

Delivator commented 6 years ago

I'm having the same problem!

paulomcnally commented 6 years ago

Have an example of implementation code?

Delivator commented 6 years ago

As the README sugsessed (https://github.com/nodenica/youtube-node#optional-parameters), I used this code:

const YouTube = require("youtube-node");

const yt= new YouTube();
yt.setKey(settings.youtubeApiKey);
yt.addParam("type", "video");

But I still get playlists in my results.

pierre-charpentier commented 6 years ago

After searching for a bit, the search method calls the clearParams method which removes the type property...

The pull request #40 should prevent the issue you are describing if it is merged.

Meanwhile, you can add the params in the search method parameters

yt.search(keyword, maxResults, { type: 'video' }, () => {
    ...
})
Delivator commented 6 years ago

@Qayou Thanks! Thats seems to be working!