+ comment renderer - woohoo!

18l-fix
Dominika Liberda 2020-12-29 07:42:23 +01:00
parent 767522c9f0
commit 1ea7e1349f
1 changed files with 29 additions and 1 deletions

View File

@ -73,6 +73,33 @@ if [[ ${get_data[v]} ]]; then
<span><i>Description</i>:<br>$(echo "$video" | jq -r '.description' | sed -E 's/$/<br>/g')</span>
</div>";
echo "<h1>Comments</h1>"
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 "<div><img src='${comment_avatar[$i]}'>
<b>${comment_nick[$i]}</b> | ${comment_published[$i]} | ${comment_likes[$i]} liked<br>
<pre>${comment_text[$i]}</pre>
</div><hr>"
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]}';
});
});
</script><h1>Playlist</h1>"
</script>"
echo "<h1>Playlist</h1>"
for (( i=0; i<${#video_id[@]}; i++ )); do
echo "<a href='watch.shs?v=${video_id[$i]}&playlist=${get_data[playlist]}'><img src='http://i.ytimg.com/vi/${video_id[$i]}/mqdefault.jpg'><br>${video_title[$i]}</a><br>"