youtube-node
youtube-node copied to clipboard
self.addPart in #search doesn't work
Hi, I'm trying to add more parts to the search function with the following code but I don't see them in the results Code:
var YouTube = require('youtube-node');
var youTube = new YouTube();
youTube.setKey('AIzaSyB1OOSpTREs85WUMvIgJvLTZKye4BVsoFU');
youTube.addPart('contentDetails');
youTube.addPart('statistics');
youTube.addPart('status');
youTube.search('World War z Trailer', 2, function(error, result) {
if (error) {
console.log(error);
}
else {
console.log(result);
}
});
Result:
etag: "\"5g01s4-wS2b4VpScndqCYc5Y-8k/suscqJikhZQTuxqt_8zSu3fP_fA\""
id: Object {kind: "youtube#video", …}
kind: "youtube#searchResult"
snippet: {
channelId: "UCkR0GY0ue02aMyM-oxwgg9g"
channelTitle: "Movieclips Coming Soon"
description: "Subscribe to TRAILERS: http://bit…://goo.gl/dHs73 Follow us on ..."
liveBroadcastContent: "none"
publishedAt: "2013-03-25T07:02:54.000Z"
thumbnails: Object {default: , …}
title: "World War Z TRAILER 2 (2013) - Brad Pitt Movie HD"
}
NM ijust noticed the search
endpoint only support the snippet
. Is there a way to get a list of search results with more data?
See https://developers.google.com/youtube/v3/docs/search/list
I made a workaround with 2 api calls. I guess there isn't a way to get everything in one shot.
module.exports.search = (q) => {
return new Promise((resolve, reject) => {
youTube.search(q, 20, (error, result) => {
if (error) return reject(error);
const ids = result.items.map(r => r.id.videoId).join(',');
youTube.getById(ids, (error, r) => {
if (error) return reject(error);
resolve(r);
});
});
});
};
Hi @danielravina have a pull request?