bashtube/webroot/comments.shs

17 lines
1.2 KiB
Bash
Executable File

#!/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 '"<h3>\(.commentsHeaderRenderer.countText.runs[0].text) Comments</h3>"' <<< "$comments" | head -1
jq -r '.commentThreadRenderer.comment.commentRenderer | select(.authorText.simpleText != null) |
"</div><div class='"'"'comment'"'"'><a href='"'"'\(.authorEndpoint.commandMetadata.webCommandMetadata.url)'"'"'><img src='"'"'\(.authorThumbnail.thumbnails[0].url)'"'"'>\(.authorText.simpleText)</a><br>",
(.contentText.runs[] | if .bold == true then "<b>\(.text)</b>" else .text end)' <<< "$comments" | sed -E 's/^$/<br>/g'