2 ms·
/*```````````youtube search html```````````*/ <M20>"\"originalUrl\":\"https://www.youtube.com/results?search_query" w=0; <M20>"ideoRenderer\":{\"videoId
by 1vuio0pswjnm7 3y ago
/*```````````youtube search html```````````*/
<M20>"\"originalUrl\":\"https://www.youtube.com/results?search_query" w=0;
<M20>"ideoRenderer\":{\"videoId\":\""[^\"]+ {
z=0;
CDp8iULPuCinsert(20);
fwrite("https://www.youtube.com/watch?v=",1,32,yyout);
for(x=27;x<yyleng;x++)putc(yytext[x],yyout);
fwrite("','",1,3,yyout);
}
<M20>"\"title\":{\"runs\":[{\"text\":\""[^\"]+ {
y=0;for(x=26;x<yyleng;x++)if(y<255){desc[y]=yytext[x];y++;};desclen=y;
}
<M20>"webCommandMetadata\":{\"url\":\"/@"[^\"]+ {
y=0;for(x=29;x<yyleng;x++)if(y<255){url[y]=yytext[x];y++;};urllen=y;
}
<M20>\"browseId\":\"[^\"]+ if(!z){
z++;
for(x=12;x<yyleng;x++)putc(yytext[x],yyout);
putc(32,yyout);
fwrite(url,1,urllen,yyout);
putc(32,yyout);
for(x=0;x<desclen;x++){if(desc[x]==39)putc(39,yyout);putc(desc[x],yyout);};
fwrite("');\n",1,4,yyout);
}
/*```````````youtube search json```````````*/
/* for timestamps from json, use yy078 */
<M20>[ ]{20,30}\"headline\":[ ]\{\n[ ]{20,30}\"runs\":[ ]\[\n[ ]{20,30}\{\n[ ]{20,30}\"text\":[ ]\"[^\"]+ {
z=0;
y=0;for(x=127;x<yyleng;x++)if(y<255){desc[y]=yytext[x];y++;};desclen=y;
}
<M20>[ ]{20,30}\"browseEndpoint\":[ ]\{\n[ ]{20,30}\"browseId\":[ ]\"[^\"]+ {
y=0;for(x=91;x<yyleng;x++){if(yytext[x])yytext[y]=yytext[x];
if(yytext[yyleng])yytext[yyleng]=0;y++;};z=y;
setenv("cid",yytext,1);
}
<M20>[ ]{29}\"canonicalBaseUrl\":[ ]\"[^\"]+ {
y=0;for(x=50;x<yyleng;x++){if(yytext[x])yytext[y]=yytext[x];
if(yytext[yyleng])yytext[yyleng]=0;y++;};w=y;
setenv("cburl",yytext,1);
}
<M20>[ ]{20,30}\"watchEndpoint\":[ ]\{\n[ ]{20,30}\"videoId\":[ ]\"[^\"]+ {
CDp8iULPuCinsert(20);
fwrite("https://www.youtube.com/watch?v=",1,32,yyout);
for(x=78;x<yyleng;x++)putc(yytext[x],yyout);
fwrite("','",1,3,yyout);
fwrite(getenv("cid"),1,z,yyout);
putc(32,yyout);
fwrite(getenv("cburl"),1,w,yyout);
putc(32,yyout);
for(x=0;x<desclen;x++){if(desc[x]==39)putc(39,yyout);putc(desc[x],yyout);};
fwrite("');\n",1,4,yyout);
}
To test:
#!/bin/sh
test $1||exec sed -n '/^ *;;/p' ${0##*/};
read x;
case $1 in :)
;;20) # youtube
shift
yy084 20 "$x depth=${1-0}"
echo ="$x"|yy076|nc -vvn 127.7 80|sed w020.htm
test $1||exit
n=1;while true;do
test $n -le ${1-0}||break
if test $n -eq 1 ;then x=020.htm; fi
if test $n -gt 1 ;then x=020.json.$((n-1)); fi
yy082 t < $x|sed 1q|yy076|nc -vvn 127.7 80|sed w020.json.$n
n=$((n+1))
done
rm 020.htm
if test $1 -gt 0;then rm 020.json.[1-9];fi
if test $1 -gt 9;then rm 020.json.[1-9][0-9];fi
esac
echo research|1.sh 20 > 20.serp
yy084 < 20.serp|sqlite3 test.db