【发布时间】:2018-08-28 08:13:28
【问题描述】:
我尝试使用 youtube API 获取 80k 视频 ID,但 youtube API 仅返回前 19 个页面,在 NextPageToken == undefined 之后,我尝试使用其他关键字和其他请求并遇到同样的问题。
async.eachSeries(check_array, function iterator(value, callback) {
console.log(next_page);
var params = {
q: q,
part: 'snippet',
maxResults: max,
order: 'title'
}
if(next_page){
params.pageToken = next_page;
}
client.search(params, function (err, data) {
//console.log(data);
if (err) throw err;
if(data.nextPageToken === "undefined"){
console.log('Its end');
}else{
next_page = data.nextPageToken;
data.items.forEach(function (value, index) {
connection.query('INSERT IGNORE INTO videos (video_id,uploaded) VALUES ("'+value.id.videoId+'",false)',
function (error, results, fields) {
if (error) throw error;
});
});
callback();
}
});
});
【问题讨论】:
-
我猜 youtube 想防止有人烧烤他们的服务器。
-
这很奇怪,因为 youtube 有 1,000,000 个 API 积分,一个请求需要 100 个积分,我大概可以解析 500,000 个视频,因为一个请求 = 50 个视频
标签: javascript node.js youtube youtube-api youtube-data-api