NodeJS를 사용하여 스크립트에 특정 재생 목록에 동영상을 삽입하는 기능을 삽입하고 싶습니다.NodeJS 동영상을 Youtube 재생 목록에 삽입
저는 인터넷에서 많은 것을 보았습니다. Youtube API가 OAuth가 작동해야한다는 것을 알고 있습니다. 따라서 일부 HTML 페이지/콜백을 통해 토큰을 얻을 수 있습니다.
나는 사용자의 개입없이 스크립트에서이 토큰을 처리하지 못하거나 무언가를 놓쳤습니까?
이 작업을 수행하는 간단한 예가 있습니까?
var express = require('express');
var router = express.Router(),
Youtube = require("youtube-api"),
fs = require('fs'),
router.get('/insert', function(req, res, next) {
Youtube.authenticate({
type: "oauth"
, token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxZ9F0sVpqEXh"
});
var req = Youtube.videos.insert({
"resource": {
// Video title and description
"snippet": {
"title": "Test",
"description": "Test video upload via YouTube API"
},
"status": {
"privacyStatus": "private"
}
},
"part": "snippet,status,id",
"media": {
"body": fs.createReadStream('./test.mp4')
}
}, function (err, data) {
console.log(err);
// insert to playlist
Youtube.playlistItems.insert({
"resource": {
"snippet": {
"playlistId": "xxxxxxxxxxxxxxxxxxxgvjIu",
"resourceId": {
"kind": "youtube#video",
"videoId": data.id // ???
}
},
"status": {
"privacyStatus": "private"
}
}
}, function (err, data) {
if (err) {
return console.log(err);
}
});
});
res.json();
});
내가 오류 401있어 :에 '로그인 필요'
EDIT 1
좋은 비디오 :
메시지를 나는이 사용하여 YouTube - API를 NPM을 시도 시작 : https://www.youtube.com/watch?v=hfWe1gPCnzc
내가 지금 토큰을 가지고 있지만이 제한을 얻을하는 방법을 알고하지 않습니다 ... 지금은 변경 :
Youtube.authenticate({ type: "oauth" , token: "token_from_google" });
그리고 오류 가지고 :
메시지 : '요청을 quota을 (를) 초과 했으므로 완료 할 수 없습니다. ' }],
코드 : 403, 메시지 : ' 이 (가) 할당량을 초과 했으므로 요청을 완료 할 수 없습니다.나는 그것을 이해할 수 없다 ...?