+ better recommended, watch JSON parser
parent
d5285e1f4d
commit
c43a6e0024
|
@ -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
|
|||
<span><i>Description</i>:<br>$(echo "$video" | jq -r '.description' | sed -E 's/$/<br>/g')</span>
|
||||
</div>";
|
||||
|
||||
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.*?</script>" | sed 's/ytInitialData = //;s/<\/script>//')"
|
||||
|
||||
|
||||
echo "<h1>Recommended</h1>"
|
||||
for i in $(echo "$vid" | grep -ohE "watch\?v\=[A-zaz0-9]{11}" | uniq | cut -c 9-19); do
|
||||
echo "<div><img src='http://i.ytimg.com/vi/$i/mqdefault.jpg'><br></div>";
|
||||
done
|
||||
echo "<h1>Recommended</h1>
|
||||
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));'>"
|
||||
|
||||
echo "<h1>Comments</h1>"
|
||||
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"
|
||||
|
||||
#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
|
||||
|
||||
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')"
|
||||
|
@ -116,8 +123,6 @@ if [[ "${get_data[v]}" ]]; then
|
|||
|
||||
[[ "$next" == '' ]] && next='dQw4w9WgXcQ'
|
||||
|
||||
echo "$next"
|
||||
|
||||
echo "<script type='text/javascript'>
|
||||
window.addEventListener('DOMContentLoaded', (event) => {
|
||||
var video = document.getElementById('player');
|
||||
|
|
Loading…
Reference in New Issue