3 ms·
Personal JSON search and channel retrieval
yy059 reformats and prints JSON
yy045 removes chunked transfer encoding
stunnel -fd 0 << eof
debug=debug
pid=/tmp/1.pid
foreground=no
[ youtube ]
accept=127.0.0.127:80
client=yes
connect=74.125.21.91:443
options=NO_TICKET
options=NO_RENEGOTIATION
renegotiation=no
sni=
sslVersion=TLSv1.3
eof
For searching YouTube:
#!/bin/sh
# usage: 1.sh query > 1.yts
# usage: yy059 < 1.yts|1.sh >> 1.yts
_x2_(){ local x=$(printf '\r\n');sed "s/ *//;s/$/$x/";};
case $# in :)
;;0) # CONTINUATION_REQUEST
KEY=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8;
MIN=\{\"context\":{\"client\":{\"hl\":\"en-US\",\"gl\":\"US\",\"clientName\":\"MWEB\",\"clientVersion\":\"2.20210916.06.01\"}},\"continuation\":;
TOKEN=$(yy059|sed -n "s/$/}/;s/\"token\":/$MIN/p"|tail -1);
test "$TOKEN"||exec echo done;
_x2_ <<eof|nc -vvn 127.127 80|yy045
POST /youtubei/v1/search?key=$KEY HTTP/1.1
Host: www.youtube.com
Content-Length: ${#TOKEN}
Content-Type: application/json
Connection: close
$TOKEN
eof
;;*) # REQUEST
S=$(echo "$@"|sed 's/ /+/g');
_x2_ <<eof|nc -vvn 127.127 80|yy045
GET /results?search_query=$S HTTP/1.1
Host: www.youtube.com
Connection: close
eof
esac;
For retrieving YouTube channels, a similar script:
#!/bin/sh
# usage: 1.sh /c/name or 1.sh /channel/ID > 1.ytc
# usage: yy059 < 1.ytc|1.sh >> 1.ytc
_x2_(){ local x=$(printf '\r\n');sed "s/ *//;s/$/$x/";};
case $# in :)
;;0) # CONTINUATION
KEY=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8;
MIN=\{\"context\":{\"client\":{\"hl\":\"en-US\",\"gl\":\"US\",\"clientName\":\"MWEB\",\"clientVersion\":\"2.20210916.06.01\"}},\"continuation\":;
TOKEN=$(yy059|sed -n "s/$/}/;s/\"token\":/$MIN/p"|sed -n \$p);
test "$TOKEN"||exec echo no more videos;
_x2_ <<eof|nc -vvn 127.127 80|yy045
POST /youtubei/v1/browse?key=$KEY HTTP/1.1
Host: www.youtube.com
Content-Length: ${#TOKEN}
Content-Type: application/json
Connection: close
$TOKEN
eof
;;*) # INITIAL
_x2_ <<eof|nc -vvn 127.127 80|yy045
GET $1/videos HTTP/1.1
Host: www.youtube.com
Connection: close
eof
esac;
Next up:
A JSON formatter to print the results as a table