From c43a6e00242e0b223464bf6e51b14c5ee0dbc43f Mon Sep 17 00:00:00 2001 From: Dominika Liberda Date: Thu, 18 Feb 2021 03:19:49 +0100 Subject: [PATCH] + better recommended, watch JSON parser --- webroot/watch.shs | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/webroot/watch.shs b/webroot/watch.shs index 533502b..82fbaad 100755 --- a/webroot/watch.shs +++ b/webroot/watch.shs @@ -4,25 +4,27 @@ if [[ "${get_data[v]}" ]]; then if [[ "${get_data[v]}" == '18l' || "${get_data[v]}" == '5eFdt6Y_34E' ]]; then uploader='MyMusicGroup' title='█▬█ █ ▀█▀ Jeden Osiem L - Jak Zapomnieć (Oficjalny Teledysk)' - url='http://sakamoto.pl/tmp/videoplayback_.webm' + url='https://sakamoto.pl/tmp/videoplayback_.webm' meta[title]=$title source templates/head.sh else - video=$(haruhi-dl $([[ ${cfg[_cookies]} != "" ]] && echo -n -- "-c ${cfg[_cookies]}") -J "http://youtube.com/watch?v=${get_data[v]}") - if [[ $video == '' ]]; then - video=$(haruhi-dl $([[ ${cfg[_cookies]} != "" ]] && echo -n -- "-c ${cfg[_cookies]}") -J "http://youtube.com/watch?v=${get_data[v]}") - if [[ $video == '' ]]; then + cd temp + video=$(haruhi-dl --write-pages $([[ ${cfg[_cookies]} != "" ]] && echo -n -- "-c ${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]}") + if [[ $video == '' ]]; then # seriously WHO DID THIS return fi fi + cd .. #echo "http://youtube.com/watch?v=${get_data[v]}" > /dev/stderr - channel_id=$(echo $video | jq -r '.channel_url' | sed -s 's/http:\/\/www.youtube.com\/channel\///') - uploader=$(echo $video | jq -r '.uploader') - title=$(echo $video | jq -r '.title') - meta[title]=$title + channel_id=$(jq -r '.channel_url' <<< "$video" | sed -s 's/http:\/\/www.youtube.com\/channel\///') + uploader=$(jq -r '.uploader' <<< "$video") + title=$(jq -r '.title' <<< "$video") + meta[title]="$title" source templates/head.sh IFS=$'\n' - urls=($(echo $video | jq -r '.formats[] | select(.format_id == "22" or .format_id == "18").url')) + urls=($(jq -r '.formats[] | select(.format_id == "22" or .format_id == "18").url' <<< "$video")) unset IFS if [[ ${urls[1]} != '' ]]; then url=${urls[1]} @@ -67,14 +69,19 @@ if [[ "${get_data[v]}" ]]; then Description:
$(echo "$video" | jq -r '.description' | sed -E 's/$/
/g')
"; - vid="$(curl -s "https://www.youtube.com/watch?v=${get_data[v]}" -c cookiejar)" + vid="$(cat "temp/${get_data[v]}_https_-_"*"watch"*".dump" | tr -d '\n' | grep -Poh "ytInitialData.*?" | sed 's/ytInitialData = //;s/<\/script>//')" + - echo "

Recommended

" - for i in $(echo "$vid" | grep -ohE "watch\?v\=[A-zaz0-9]{11}" | uniq | cut -c 9-19); do - echo "

"; - done + echo "

Recommended

+
" - echo "

Comments

" + jq -r '.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults.results[] | .compactAutoplayRenderer.contents[0].compactVideoRenderer, .compactVideoRenderer | if .videoId != null then "
"+.title.simpleText+"
" else empty end' <<< "$vid" + + #for i in $(grep -ohE "watch\?v\=[A-zaz0-9]{11}" <<< "$vid" | cut -c 9-19 | uniq); do + # echo "

"; + #done + + echo "

Comments

" 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')" @@ -116,8 +123,6 @@ if [[ "${get_data[v]}" ]]; then [[ "$next" == '' ]] && next='dQw4w9WgXcQ' - echo "$next" - echo "