곽교린

Update CommentLoadingTest.js, papago.js

modify papago.js import to require. add comment language(lang) in commen
tList by require papago.js in CommentLoadingTest.
var papago = require("./papago.js");
var http = require('http');
var fs = require('fs');
var url = require('url');
......@@ -8,6 +10,7 @@ const {google} = require("googleapis");
const service = google.youtube('v3');
const apiKey = 'AIzaSyCjBrFKnBlGvxsfOD-qJP8nBkdEoqKRHu8'; //api키
let videoNum = "TpPwI_Lo0YY"; //비디오 주소(예시)
const serverIP = "http://localhost:3000" //서버의 주소
var commentList = new Array();
var commentNum = 0;
var savednpt = ''
......@@ -29,7 +32,7 @@ function showcomment(response, VideoNum){
<meta charset="utf-8">
</head>
<body>
<form action="http://localhost:3000/search" method="get">
<form action="${serverIP}/search" method="get">
<p>
<textarea name="videourl" placeholder="Write your video Url" >${VideoNum}</textarea>
</p>
......@@ -42,7 +45,7 @@ function showcomment(response, VideoNum){
<iframe width="560" height="315" src="https://www.youtube.com/embed/${VideoNum}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<br>
<a href="http://localhost:3000/search?videourl=${VideoNum}&nextpage=${savednpt}"><input type="button" value="댓글 더 불러오기"></a>
<a href="${serverIP}/search?videourl=${VideoNum}&nextpage=${savednpt}"><input type="button" value="댓글 더 불러오기"></a>
<br>
${commentDisplay}
</body>
......@@ -64,10 +67,12 @@ function loadcomment(ApiKey, VideoNum, npt, n, res){
}).then(function(response) {
//console.log("Response", response);
for(let iter = 0; iter < response.data.pageInfo.totalResults; iter++){
let templang = papago.getLang(response.data.items[iter].snippet.topLevelComment.snippet.textDisplay)
let tempComment = {
'name' : response.data.items[iter].snippet.topLevelComment.snippet.authorDisplayName,
'image' : response.data.items[iter].snippet.topLevelComment.snippet.authorProfileImageUrl,
'text' : response.data.items[iter].snippet.topLevelComment.snippet.textDisplay
'text' : response.data.items[iter].snippet.topLevelComment.snippet.textDisplay,
'lang' : templang
}
commentList.push(tempComment);
commentNum += 1;
......@@ -106,7 +111,7 @@ var app = http.createServer(function(request,response){ // request는 브라우
<meta charset="utf-8">
</head>
<body>
<form action="http://localhost:3000/search" method="get">
<form action="${serverIP}/search" method="get">
<p>
<textarea name="videourl" placeholder="Write your video Url"></textarea>
</p>
......
This diff is collapsed. Click to expand it.
{
"dependencies": {
"googleapis": "^100.0.0",
"youtube-v3-api": "^1.1.1",
"franc": "^6.0.0",
"langs": "^2.0.0"
},
"type": "module"
"googleapis": "^100.0.0",
"langs": "^2.0.0",
"request": "^2.88.2",
"youtube-v3-api": "^1.1.1"
}
}
......
var express = require('express');
var app = express();
var client_id = '6hpmInU0TCrQIiiJwgJX';
var client_secret = 'jpYZbkj0_g';
// var query = "언어를 감지할 문장을 입력하세요.";
......@@ -51,8 +50,13 @@ async function findLanguage(sourceText) {
});
});
}
/*
export async function getLang(comment) {
const lang = await findLanguage(comment);
return lang;
}
*/
exports.getLang = async function(comment) {
const lang = await findLanguage(comment);
return lang;
}
\ No newline at end of file
......