#!/bin/bash if [[ "${get_data[v]}" == '' && "${get_data[cont]}" == '' ]]; then echo "pffft" return fi if [[ "${get_data[cont]}" == '' ]]; then # tactical replies, INCOMING vid="$(curl -b cookiejar_ -H "Cookie: CONSENT=YES+1337" -s "https://www.youtube.com/watch?v=${get_data[v]}" -c cookiejar_)" cont="$(grep -Poh 'token":"Eg0S.*?"' <<< "$vid" | sed -E 's/token"://;s/"//g')" #' else cont="${get_data[cont]}" fi 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[] | if(.reloadContinuationItemsCommand != null) then .reloadContinuationItemsCommand.continuationItems[] else .appendContinuationItemsAction.continuationItems[] end')" jq -r 'select(.commentsHeaderRenderer) | "

(whole \(.commentsHeaderRenderer.countText.runs[0].text) of them)

"' <<< "$comments" | head -1 jq -r '(if (.commentThreadRenderer != null) then .commentThreadRenderer | select(.comment.commentRenderer.authorText.simpleText != null) else .commentRenderer end | ( if (.comment.commentRenderer != null) then .comment.commentRenderer else . end | "
\(.authorText.simpleText) \(.publishedTimeText.runs[].text)
",
				(.contentText.runs[] | if .bold == true then "\(.text)" else .text end),
				(select(.voteCount.simpleText != null) | "
\(.voteCount.simpleText) liked") ), (select(.replies.commentRepliesRenderer) | "
Show replies
")) ' <<< "$comments" | sed -E 's/^$/
/g' echo "
" jq -r ' if (.continuationItemRenderer.continuationEndpoint) then select(.continuationItemRenderer.continuationEndpoint.continuationCommand.token) | "
Load more...
" else select(.continuationItemRenderer.button.buttonRenderer.command.continuationCommand.token) | "
More replies...
" end' <<< "$comments" | tail -1