Yuncheol Kwak

Feat get korean percentage

1 { 1 {
2 - "youtubeAPI" : "",//insert your youtube API key. 2 + "youtubeAPI" : "ENTER YOUR GOOGLE API KEY",
3 - "papagoClientID" : "", //insert your papago client ID. 3 + "papagoClientID" : "ENTER YOUR NAVER CLIENT ID",
4 - "papagoClientSecret":"" //insert your papago client secret. 4 + "papagoClientSecret":"ENTER YOUR NAVER CLIENT SECRET"
5 } 5 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -14,14 +14,25 @@ var videoLang = 'all'; //설정 언어 ...@@ -14,14 +14,25 @@ var videoLang = 'all'; //설정 언어
14 const serverIP = "http://localhost:3000" //서버의 주소 14 const serverIP = "http://localhost:3000" //서버의 주소
15 var commentList = new Array(); 15 var commentList = new Array();
16 var commentNum = 0; 16 var commentNum = 0;
17 -var savednpt = '' 17 +var korNum = 0;
18 +var savednpt = '';
18 const URLreg1 = new RegExp(/https?:\/\/youtu.be\//);//유튜브에서 제공하는 동영상 공유 기능을 사용하여 얻은 URL 형식 19 const URLreg1 = new RegExp(/https?:\/\/youtu.be\//);//유튜브에서 제공하는 동영상 공유 기능을 사용하여 얻은 URL 형식
19 const URLreg2 = new RegExp(/https?:\/\/www.youtube.com\//);//유튜브 주소를 그대로 넣었을 때 URL형식 20 const URLreg2 = new RegExp(/https?:\/\/www.youtube.com\//);//유튜브 주소를 그대로 넣었을 때 URL형식
20 21
21 function showcomment(response, VideoNum){ 22 function showcomment(response, VideoNum){
22 let commentDisplay = ''; 23 let commentDisplay = '';
23 for(let iterArr = 0; iterArr < commentNum; iterArr++){ 24 for(let iterArr = 0; iterArr < commentNum; iterArr++){
24 - commentDisplay += `<br>${commentList[iterArr].name}<br>${commentList[iterArr].text}<br><br>`; 25 + commentDisplay += `
26 + <div style="margin-top:15px; display:flex">
27 + <div style="margin-right:10px">
28 + <img class="rounded-circle" src="${commentList[iterArr].image}">
29 + </div>
30 + <div>
31 + <b>${commentList[iterArr].name}</b>
32 + <p>${commentList[iterArr].text}</p>
33 + </div>
34 + </div>
35 + `;
25 } 36 }
26 let body = ` 37 let body = `
27 <!doctype html> 38 <!doctype html>
...@@ -58,11 +69,13 @@ function showcomment(response, VideoNum){ ...@@ -58,11 +69,13 @@ function showcomment(response, VideoNum){
58 </form> 69 </form>
59 <br> 70 <br>
60 <br> 71 <br>
61 - <div class="embed-responsive embed-responsive-16by9" style="text-align:center;"> 72 + <div class="embed-responsive embed-responsive-16by9" style="text-align:center">
62 <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> 73 <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>
63 </div> 74 </div>
64 <br> 75 <br>
76 + <div id="liveAlertPlaceholder"></div>
65 <a class="btn btn-dark" href="${serverIP}/search?videourl=${VideoNum}&nextpage=${savednpt}&languages=${videoLang}" role="button">Show more comments</a> 77 <a class="btn btn-dark" href="${serverIP}/search?videourl=${VideoNum}&nextpage=${savednpt}&languages=${videoLang}" role="button">Show more comments</a>
78 + <button type="button" class="btn btn-danger" onclick="alert('Korean Percent: ${Math.floor((korNum/commentNum)*10000)/100}%')">Get Kor Percent</button>
66 <br> 79 <br>
67 ${commentDisplay} 80 ${commentDisplay}
68 </body> 81 </body>
...@@ -105,6 +118,7 @@ function loadcomment(ApiKey, VideoNum, npt, n, res){ ...@@ -105,6 +118,7 @@ function loadcomment(ApiKey, VideoNum, npt, n, res){
105 templang = await langPromise; 118 templang = await langPromise;
106 if(videoLang == 'all' || videoLang == templang){ 119 if(videoLang == 'all' || videoLang == templang){
107 commentList.push(tempcommentList[iter]); 120 commentList.push(tempcommentList[iter]);
121 + if(templang=="ko"){korNum++;}
108 commentNum++; 122 commentNum++;
109 } 123 }
110 } 124 }
...@@ -179,6 +193,7 @@ var app = http.createServer(function(request,response){ // request는 브라우 ...@@ -179,6 +193,7 @@ var app = http.createServer(function(request,response){ // request는 브라우
179 else if(pathname === '/search'){ 193 else if(pathname === '/search'){
180 commentList.splice(0); 194 commentList.splice(0);
181 commentNum = 0; //코멘트 리스트 초기화 195 commentNum = 0; //코멘트 리스트 초기화
196 + korNum = 0;
182 197
183 videoNum = queryData.videourl; 198 videoNum = queryData.videourl;
184 videoLang = queryData.languages; 199 videoLang = queryData.languages;
...@@ -190,7 +205,7 @@ var app = http.createServer(function(request,response){ // request는 브라우 ...@@ -190,7 +205,7 @@ var app = http.createServer(function(request,response){ // request는 브라우
190 //유튜브 URL공유 기능을 사용하여 얻은 주소를 넣었을 때 videoNum 추출 205 //유튜브 URL공유 기능을 사용하여 얻은 주소를 넣었을 때 videoNum 추출
191 videoNum = videoNum.replace(URLreg1,""); 206 videoNum = videoNum.replace(URLreg1,"");
192 console.log(videoNum); 207 console.log(videoNum);
193 - let npt = "" 208 + let npt = "";
194 if(queryData.nextpage != null) npt = queryData.nextpage 209 if(queryData.nextpage != null) npt = queryData.nextpage
195 loadcomment(apiKey,videoNum,npt,5, response); 210 loadcomment(apiKey,videoNum,npt,5, response);
196 } 211 }
......