Toggle navigation
Toggle navigation
This project
Loading...
Sign in
곽윤철
/
youtube-comment-seperator
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Yuncheol Kwak
2022-06-03 17:54:43 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bcbead07ccf81e37b3c04220d5e1d079f4167c79
bcbead07
1 parent
85285a27
Feat get korean percentage
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
7 deletions
APIs.json
CommentLoadingTest.js
APIs.json
View file @
bcbead0
{
"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
...
...
CommentLoadingTest.js
View file @
bcbead0
...
...
@@ -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
=
''
;
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
);
}
...
...
Please
register
or
login
to post a comment