test.js 1.33 KB
//https://www.npmjs.com/package/youtube-v3-api
//http://khuhub.khu.ac.kr/2019102147/youtube-comment-seperator.git

const apiKey = 'AIzaSyCjBrFKnBlGvxsfOD-qJP8nBkdEoqKRHu8';
const {google} = require("googleapis");
const service = google.youtube('v3');

service.commentThreads.list({
    "key":apiKey,
    "part":[
        "snippet, replies"
    ],
    "videoId":"m1gHR4dJhKU"//비디오 주소
}).then(function(response) {
    console.log("Response", response);
    console.log(response.data.items[0].snippet.topLevelComment.snippet.textDisplay)
    console.log(response.data.items[1].snippet.topLevelComment.snippet.textDisplay)
  },
  function(err) { console.error("Execute error", err); });


/*
service.comments.list({
    "key": apiKey,
    "part": [
        "snippet"
      ],
      "parentId": "UgzDE2tasfmrYLyNkGt4AaABAg"
}).then(function(response) {
    // Handle the results here (response.result has the parsed body).
    console.log("Response", response);
    console.log(response.data.items)
  },
  function(err) { console.error("Execute error", err); });

const {YoutubeDataAPI} = require("youtube-v3-api");
const {google} = require("googleapis");

const api = new YoutubeDataAPI(apiKey);

api.searchComments("https://youtu.be/m1gHR4dJhKU").then((data)=>{
    console.log(data);
    console.log(data.pageInfo);
},(err)=>{
    console.error(err);
})
*/