Yuncheol Kwak

Feat get korean percentage

{
"youtubeAPI" : "",//insert your youtube API key.
"papagoClientID" : "", //insert your papago client ID.
"papagoClientSecret":"" //insert your papago client secret.
"youtubeAPI" : "ENTER YOUR GOOGLE API KEY",
"papagoClientID" : "ENTER YOUR NAVER CLIENT ID",
"papagoClientSecret":"ENTER YOUR NAVER CLIENT SECRET"
}
\ No newline at end of file
......
......@@ -14,14 +14,25 @@ var videoLang = 'all'; //설정 언어
const serverIP = "http://localhost:3000" //서버의 주소
var commentList = new Array();
var commentNum = 0;
var savednpt = ''
var korNum = 0;
var savednpt = '';
const URLreg1 = new RegExp(/https?:\/\/youtu.be\//);//유튜브에서 제공하는 동영상 공유 기능을 사용하여 얻은 URL 형식
const URLreg2 = new RegExp(/https?:\/\/www.youtube.com\//);//유튜브 주소를 그대로 넣었을 때 URL형식
function showcomment(response, VideoNum){
let commentDisplay = '';
let commentDisplay = '';
for(let iterArr = 0; iterArr < commentNum; iterArr++){
commentDisplay += `<br>${commentList[iterArr].name}<br>${commentList[iterArr].text}<br><br>`;
commentDisplay += `
<div style="margin-top:15px; display:flex">
<div style="margin-right:10px">
<img class="rounded-circle" src="${commentList[iterArr].image}">
</div>
<div>
<b>${commentList[iterArr].name}</b>
<p>${commentList[iterArr].text}</p>
</div>
</div>
`;
}
let body = `
<!doctype html>
......@@ -58,11 +69,13 @@ function showcomment(response, VideoNum){
</form>
<br>
<br>
<div class="embed-responsive embed-responsive-16by9" style="text-align:center;">
<div class="embed-responsive embed-responsive-16by9" style="text-align:center">
<iframe class="embed-responsive-item" 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>
</div>
<br>
<div id="liveAlertPlaceholder"></div>
<a class="btn btn-dark" href="${serverIP}/search?videourl=${VideoNum}&nextpage=${savednpt}&languages=${videoLang}" role="button">Show more comments</a>
<button type="button" class="btn btn-danger" onclick="alert('Korean Percent: ${Math.floor((korNum/commentNum)*10000)/100}%')">Get Kor Percent</button>
<br>
${commentDisplay}
</body>
......@@ -105,6 +118,7 @@ function loadcomment(ApiKey, VideoNum, npt, n, res){
templang = await langPromise;
if(videoLang == 'all' || videoLang == templang){
commentList.push(tempcommentList[iter]);
if(templang=="ko"){korNum++;}
commentNum++;
}
}
......@@ -179,6 +193,7 @@ var app = http.createServer(function(request,response){ // request는 브라우
else if(pathname === '/search'){
commentList.splice(0);
commentNum = 0; //코멘트 리스트 초기화
korNum = 0;
videoNum = queryData.videourl;
videoLang = queryData.languages;
......@@ -190,7 +205,7 @@ var app = http.createServer(function(request,response){ // request는 브라우
//유튜브 URL공유 기능을 사용하여 얻은 주소를 넣었을 때 videoNum 추출
videoNum = videoNum.replace(URLreg1,"");
console.log(videoNum);
let npt = ""
let npt = "";
if(queryData.nextpage != null) npt = queryData.nextpage
loadcomment(apiKey,videoNum,npt,5, response);
}
......