* tempfix for comments

18l-fix
Dominika Liberda 2021-02-18 03:50:41 +01:00
parent c43a6e0024
commit d8517f545a
4 changed files with 14 additions and 10 deletions

View File

@ -1 +1,2 @@
cfg[title]='BashTube'
cfg[title]='BashTube'
cfg[_cookies]='cookiejar'

View File

@ -1,7 +1,7 @@
#!/bin/bash
if session_verify "${cookies[sh_session]}" && [[ "${get_data[v]}" != '' ]]; then
title=$(haruhi-dl $([[ ${cfg[_cookies]} != "" ]] && echo -n -- "-c ${cfg[_cookies]}") -e "https://youtube.com/watch?v=${get_data[v]}")
title=$(haruhi-dl --cookies ${cfg[_cookies]} -e "https://youtube.com/watch?v=${get_data[v]}")
if [[ $(grep -F "$title" storage/faves | grep "$(echo ${cookies[username]} | sed -E "s/\r//")") == '' ]]; then
echo "$(session_get_username ${cookies[sh_session]}):${get_data[v]}:$title" >> storage/faves
fi

View File

@ -4,7 +4,7 @@ meta[title]="$title"
source templates/head.sh
if [[ "${get_data[list]}" ]]; then
data=$(haruhi-dl $([[ ${cfg[_cookies]} != "" ]] && echo -n -- "-c ${cfg[_cookies]}") -j --flat-playlist "https://www.youtube.com/playlist?list=${get_data[list]}")
data=$(haruhi-dl --cookies ${cfg[_cookies]} -j --flat-playlist "https://www.youtube.com/playlist?list=${get_data[list]}")
else
echo "Please specify id"
return

View File

@ -9,9 +9,9 @@ if [[ "${get_data[v]}" ]]; then
source templates/head.sh
else
cd temp
video=$(haruhi-dl --write-pages $([[ ${cfg[_cookies]} != "" ]] && echo -n -- "-c ${cfg[_cookies]}") -J "http://youtube.com/watch?v=${get_data[v]}")
video=$(haruhi-dl --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}")
if [[ $video == '' ]]; then # okay who did this
video=$(haruhi-dl --write-pages $([[ ${cfg[_cookies]} != "" ]] && echo -n -- "-c ${cfg[_cookies]}") -J "http://youtube.com/watch?v=${get_data[v]}")
video=$(haruhi-dl --write-pages --cookies ${cfg[_cookies]} -J "http://youtube.com/watch?v=${get_data[v]}")
if [[ $video == '' ]]; then # seriously WHO DID THIS
return
fi
@ -69,24 +69,27 @@ if [[ "${get_data[v]}" ]]; then
<span><i>Description</i>:<br>$(echo "$video" | jq -r '.description' | sed -E 's/$/<br>/g')</span>
</div>";
vid="$(cat "temp/${get_data[v]}_https_-_"*"watch"*".dump" | tr -d '\n' | grep -Poh "ytInitialData.*?</script>" | sed 's/ytInitialData = //;s/<\/script>//')"
vid="$(cat "temp/${get_data[v]}_https_-_"*"watch"*".dump")"
vid_json="$(tr -d '\n' <<< "$vid" | grep -Poh "ytInitialData.*?</script>" | sed 's/ytInitialData = //;s/<\/script>//')"
echo "<h1>Recommended</h1>
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));'>"
jq -r '.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults.results[] | .compactAutoplayRenderer.contents[0].compactVideoRenderer, .compactVideoRenderer | if .videoId != null then "<div><a href='"'"'/watch?v="+.videoId+"'"'"'><img src='"'"'https://i.ytimg.com/vi/"+.videoId+"/mqdefault.jpg'"'"'>"+.title.simpleText+"</a></div>" else empty end' <<< "$vid"
jq -r '.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults.results[] | .compactAutoplayRenderer.contents[0].compactVideoRenderer, .compactVideoRenderer | if .videoId != null then "<div><a href='"'"'/watch?v="+.videoId+"'"'"'><img src='"'"'https://i.ytimg.com/vi/"+.videoId+"/mqdefault.jpg'"'"'>"+.title.simpleText+"</a></div>" else empty end' <<< "$vid_json"
#for i in $(grep -ohE "watch\?v\=[A-zaz0-9]{11}" <<< "$vid" | cut -c 9-19 | uniq); do
# echo "<div><a href='/watch?v=$i'><img src='https://i.ytimg.com/vi/$i/mqdefault.jpg'></a><br></div>";
#done
vid="$(curl -s "https://www.youtube.com/watch?v=LACbVhgtx9I" -c cookiejar_)" # broken comment support, we need this for now
echo "</div><h1>Comments</h1>"
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 -s '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)"
comments="$(curl -vvv '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"))
@ -108,7 +111,7 @@ if [[ "${get_data[v]}" ]]; then
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]}")
playlist=$(haruhi-dl --cookies ${cfg[_cookies]} -j --flat-playlist "https://www.youtube.com/playlist?list=${get_data[playlist]}")
IFS=$'\n'
video_title=($(jq -r '.title' <<< $playlist))