diff --git a/webroot/comments.shs b/webroot/comments.shs
new file mode 100755
index 0000000..e2c98ad
--- /dev/null
+++ b/webroot/comments.shs
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+vid="$(curl -b cookiejar_ -H "Cookie: CONSENT=YES+1337" -s "https://www.youtube.com/watch?v=${get_data[v]}" -c cookiejar_)" # broken comment support, we need this for now
+
+cont="$(grep -Poh 'token":"Eg0S.*?"' <<< "$vid" | sed -E 's/token"://;s/"//g')" #'
+comments="$(curl -s 'https://www.youtube.com/youtubei/v1/next?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8' \
+ --compressed -H 'Content-Type: application/json' \
+ --data-raw '{"context":{"client":{"hl":"en","gl":"GB","clientName":"WEB","clientVersion":"2.20210719.00.00","mainAppWebInfo":{}},"adSignalsInfo":{"params":[]}},"continuation":"'"$cont"'"}' \
+ | jq '.onResponseReceivedEndpoints[].reloadContinuationItemsCommand.continuationItems[]')"
+
+
+ jq -r '"
\(.authorText.simpleText)",
+ (.contentText.runs[] | if .bold == true then "
\(.text)" else .text end)' <<< "$comments" | sed -E 's/^$/
/g'
+
diff --git a/webroot/css/style.css b/webroot/css/style.css
index 94cdc90..e3a8e67 100644
--- a/webroot/css/style.css
+++ b/webroot/css/style.css
@@ -4,6 +4,10 @@
pre {
white-space: pre-wrap;
}
+.comment {
+ margin-top: 5px;
+ margin-bottom: 15px;
+}
.hide-cursor {
cursor: none;
diff --git a/webroot/js/watch.js b/webroot/js/watch.js
new file mode 100644
index 0000000..170af7f
--- /dev/null
+++ b/webroot/js/watch.js
@@ -0,0 +1,17 @@
+window.addEventListener("load", () => {
+ const comments = document.querySelector(".comments");
+ const id = new URLSearchParams(document.location.search).get("v");
+ comments.innerText = "Loading...";
+ fetch("/comments.shs?v=" + id).then(
+ res => {
+ if (res.status !== 200) {
+ throw new Error('HTTP Error ' + res.status);
+ }
+ return res.text();
+ }
+ ).then(
+ res => comments.innerHTML = res
+ ).catch(
+ err => comments.innerText = 'Error during fetching comments: ' + err.message
+ )
+})
diff --git a/webroot/watch.shs b/webroot/watch.shs
index aa86768..ab37cba 100755
--- a/webroot/watch.shs
+++ b/webroot/watch.shs
@@ -154,29 +154,7 @@ if [[ "${get_data[v]}" ]]; then
strings[recommended]=$(jq -r '.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults.results[] | .compactAutoplayRenderer.contents[0].compactVideoRenderer, .compactVideoRenderer | if .videoId != null then "
" else empty end' <<< "$vid_json")
- vid="$(curl -b cookiejar_ -H "Cookie: CONSENT=YES+1337" -s "https://www.youtube.com/watch?v=${get_data[v]}" -c cookiejar_)" # broken comment support, we need this for now
-
- cont="$(grep -Poh 'continuation":".*?"' <<< "$vid" | sed -E 's/.*":"//g;s/"//g')"
- CSRF="$(grep -Poh 'XSRF_TOKEN":".*?"' <<< "$vid" | sed -E 's/XSRF_TOKEN":"//g;s/"//g;s/\\u00/%/g')"
- itct="$(grep -Poh '","clickTrackingParams":".*?"' <<< "$vid" | sed -E 's/.*":"//g;s/"//g;s/\=/%3d/g')"
-
- comments="$(curl -s 'https://www.youtube.com/comment_service_ajax?action_get_comments=1&pbj=1&ctoken='"$cont"'&continuation='"$cont"'&itct='"$itct" -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'X-YouTube-Client-Name: 1' -H 'X-YouTube-Client-Version: 2.20201105.01.01' --data-raw 'session_token='"$CSRF" -b cookiejar_)"
-
- IFS=$'\n'
- comment_nick=($(jq -r '.response.continuationContents.itemSectionContinuation.contents[].commentThreadRenderer.comment.commentRenderer.authorText.simpleText' <<< "$comments"))
- comment_published=($(jq -r '.response.continuationContents.itemSectionContinuation.contents[].commentThreadRenderer.comment.commentRenderer.publishedTimeText.runs[0].text' <<< "$comments"))
- comment_likes=($(jq -r '.response.continuationContents.itemSectionContinuation.contents[].commentThreadRenderer.comment.commentRenderer.voteCount.simpleText' <<< "$comments"))
- comment_avatar=($(jq -r '.response.continuationContents.itemSectionContinuation.contents[].commentThreadRenderer.comment.commentRenderer.authorThumbnail.thumbnails[1].url' <<< "$comments"))
- unset IFS
- x=$(jq '.response.continuationContents.itemSectionContinuation.contents[].commentThreadRenderer.comment.commentRenderer.contentText.runs | map(.text)' <<< "$comments")
- IFS=']'
- for i in $x; do
- comment_text+=($(echo "$i]" | jq -r 'join("")')) # sincerely, fsck [] shell expansion
- done
-
- for (( i=0; i<${#comment_nick[@]}; i++ )); do
- strings[comments_list]+=$(echo "
${comment_nick[$i]} | ${comment_published[$i]} | ${comment_likes[$i]} liked
${comment_text[$i]}
")
- done
+ strings[comments_list]=""
strings[playlist]=""