From 1ea7e1349fc8aa9a59dd8b0eb12f0b2ccb7c341d Mon Sep 17 00:00:00 2001 From: Dominika Liberda Date: Tue, 29 Dec 2020 07:42:23 +0100 Subject: [PATCH] + comment renderer - woohoo! --- webroot/yt/watch.shs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/webroot/yt/watch.shs b/webroot/yt/watch.shs index dfeae94..845fbd9 100755 --- a/webroot/yt/watch.shs +++ b/webroot/yt/watch.shs @@ -73,6 +73,33 @@ if [[ ${get_data[v]} ]]; then Description:
$(echo "$video" | jq -r '.description' | sed -E 's/$/
/g')
"; + echo "

Comments

" + + vid="$(curl -s "https://www.youtube.com/watch?v=${get_data[v]}" -c cookiejar)" + cont="$(echo "$vid" | grep -Poh 'continuation":".*?"' | sed -E 's/.*":"//g;s/"//g')" + CSRF="$(echo "$vid" | grep -Poh 'XSRF_TOKEN":".*?"' | sed -E 's/XSRF_TOKEN":"//g;s/"//g;s/\\u00/%/g')" + + comments="$(curl 'https://www.youtube.com/comment_service_ajax?action_get_comments=1&pbj=1&ctoken='"$cont"'&continuation='"$cont" -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.likeCount' <<< "$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 + echo "
+ ${comment_nick[$i]} | ${comment_published[$i]} | ${comment_likes[$i]} liked
+
${comment_text[$i]}
+

" + done + if [[ ${get_data[playlist]} ]]; then playlist=$(haruhi-dl $([[ ${cfg[_cookies]} != "" ]] && echo -n -- "-c ${cfg[_cookies]}") -j --flat-playlist https://www.youtube.com/playlist?list=${get_data[playlist]}) @@ -97,7 +124,8 @@ if [[ ${get_data[v]} ]]; then window.location = 'watch.shs?v=$next&playlist=${get_data[playlist]}'; }); }); -

Playlist

" + " + echo "

Playlist

" for (( i=0; i<${#video_id[@]}; i++ )); do echo "
${video_title[$i]}

"