곽교린

Merge branch 'master' of http://khuhub.khu.ac.kr/2019102147/youtube-comment-seperator into develop

import {franc} from 'franc';
import langs from 'langs';
function getLang(se) {
let langCode = "";
if(se.length < 10) {
langCode = franc(se, {minLength:`${se.length}`});
} else {
langCode = franc(se);
}
return langs.where('3', langCode).local;
}
export {getLang};
\ No newline at end of file
//https://developers.google.com/youtube/v3/docs/commentThreads/list
//http://khuhub.khu.ac.kr/2019102147/youtube-comment-seperator.git
const apiKey = 'AIzaSyCjBrFKnBlGvxsfOD-qJP8nBkdEoqKRHu8';
let videoNum = "m1gHR4dJhKU";
const {google} = require("googleapis");
const service = google.youtube('v3');
var npt = ""
for(let i = 0; i < 3; i++){
console.log(npt);
service.commentThreads.list({
"key":apiKey,
"part":[
"snippet, replies"
],
"videoId":videoNum,//비디오 주소
"maxResults" : 10,
"pageToken" : npt
}).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);
npt = JSON.parse(response.data.nextPageToken);
},
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);
})
*/
\ No newline at end of file