[–] 1vuio0pswjnm7 2y ago ↗ // yy079 part 1 of 2 #include <time.h> int setenv (const char *, const char *, int); int unsetenv (const char *); int fileno (FILE *); int t,v,w,x,y,z; char ch; int append; int itag; int idx; int url1; int url2; int title; int itag18; int itag22; int lastModified; int lenh(int n){int h,s;s=n%(24*3600);h=s/3600 ;return(h);} int lenm(int n){int m,s;s=n%(24*3600);s=s%3600;m=s/60;return(m);} int lens(int n){int s;s=n%(24*3600);s=s%3600;s=s%60;return(s);} time_t xt; struct tm *yt; char zt[100]; int author, lengthS; %option nounput noinput noyywrap %% ^HTTP\/1.1[ ]200[ ]OK\r { itag = 0;title = 0; url1 = 0;url2 = 0; itag18 = 0;itag22 = 0;author=0;lengthS = 0; unsetenv("url1");unsetenv("url2"); lastModified = 0; } \"itag\":[ ]18, { itag=18;itag18++; } \"itag\":[ ]22, { itag=22;itag22++; } \"url\":[ ]\"https:\/\/rr[^\n]+itag=18[^\n]+\", { t=1; if(itag18) { y=0;for(x=8;x<yyleng-2;x++){if(yytext[x])yytext[y]=yytext[x];y++;}; if(yytext[yyleng-10])yytext[yyleng-10]=0; setenv("url1",yytext,1); } } \"url\":[ ]\"https:\/\/rr[^\n]+itag=22[^\n]+\", { t=2; if(itag22) { y=0;for(x=8;x<yyleng-2;x++){if(yytext[x])yytext[y]=yytext[x];y++;}; if(yytext[yyleng-10])yytext[yyleng-10]=0; setenv("url2",yytext,1); } } \"lastModified\":[ ]\"[0-9]{10} { idx++; if(!append) if(idx==1){fprintf(stdout,"<!-- 9999999999 --><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">"); fprintf(stdout,"<pre><table style=\"margin:0px;padding:0px\" cellspacing=0 cellpadding=0>\n");}; if(itag18) if(!lastModified) { y=0;for(x=17;x<yyleng;x++){if(yytext[x])yytext[y]=yytext[x];y++;}; if(yytext[yyleng-17])yytext[yyleng-17]=0; fprintf(stdout,"<!-- %s --><tr><td>",yytext); xt=atoi(yytext); yt=localtime(&xt); if(strftime(zt,sizeof(zt),"%d %b %Y %H:%M:%S %Z",yt)!=0) {fwrite(zt,24,1,stdout);putc(44,stdout);}; lastModified++; } t = 0; } ^[ ]{4}\"videoId\":[ ]\"[^\n]{11}\", { if(getenv("url2"))
[–] 1vuio0pswjnm7 2y ago ↗ // yy079 part 2 of 2 if(!url2) {fprintf(stdout,"<a href=%s target=_blank>",getenv("url2"));unsetenv("url1");url2++;} if(getenv("url1")) if(!url1) {fprintf(stdout,"<a href=%s&range: bytes=0- target=_blank>",getenv("url1"));url1++;}; if(itag>0) { /* fprintf(stdout,"%02d,",itag); */ for(x=16;x<yyleng-1;x++)if(yytext[x]!=34)putc(yytext[x],stdout); if(url1|url2)fwrite("</a>,",5,1,stdout);else putc(44,stdout); } } \"title\":[ ]\"[^\n]+\", { if(itag>0) { ch = 0; for(x=9;x<yyleng;x++) { if(yytext[x]==92)ch=yytext[x]; if(yytext[x]==34&&ch!=0){putc(34,stdout);ch = 0;}; if(yytext[x]!=34&&yytext[x]!=92&&ch!=0){putc(ch,stdout);putc(yytext[x],stdout);ch = 0;}; if(ch==0&&yytext[x]!=92&&yytext[x]!=44)putc(yytext[x],stdout); if(yytext[yyleng])yytext[yyleng]=0; } title = 1; putc(44,stdout); } } \"lengthSeconds\":[ ]\"[^\"\n]+ { if(itag>0) if(lengthS==0) { y=0;for(x=18;x<yyleng;x++){if(yytext[x])yytext[y]=yytext[x];y++;}; if(yytext[yyleng-18])yytext[yyleng-18]=0; w=atoi(yytext); fprintf(stdout,"%02d:%02d:%02d,",lenh(w),lenm(w),lens(w)); fwrite(yytext,1,yyleng-18,yyout); putc(44,stdout); lengthS++; } } ^[ ]{4}\"channelId\":[ ]\"UC[-A-Z0-9a-z_]{22}\", { if(itag>0) { for(x=18;x<yyleng;++x) if(yytext[x]!=34)putc(yytext[x],stdout); } } \"viewCount\":[ ]\"[0-9]+\", { if(itag>0) if(!author) { for(x=14;x<yyleng;++x) if(yytext[x]!=34)putc(yytext[x],stdout); } } \"author\":[ ]\"[^\n]+\", { author++; if(itag>0) { ch = 0; for(x=10;x<yyleng-1;x++) { if(yytext[x]==92)ch=yytext[x]; if(yytext[x]==34&&ch!=0){putc(34,stdout);ch = 0;}; if(yytext[x]!=34&&yytext[x]!=92&&ch!=0){putc(ch,stdout);putc(yytext[x],stdout);ch = 0;}; if(ch==0&&yytext[x]!=92)putc(yytext[x],stdout); } putc(10,stdout); } } .|\n %% int main(int argc,char* *argv) { if(argc>0)if(argv[1])if(argv[1][0]==97)append++; yylex(); exit(0); }
[–] 1vuio0pswjnm7 2y ago ↗ Retrieve, remove indent, compile, strip #!/bin/sh x=https://news.ycombinator.com/item?id links -dump $x=37083675|sed -n '6,82s/.\{7\}//p' > 079.l links -dump $x=37083946|sed -n '6,84s/.\{7\}//p' >> 079.l flex -8Crf 079.l cc -O3 -std=c89 -W -Wall -pedantic -pipe lex.yy.c -static -o yy079 strip -s yy079 [–] 1vuio0pswjnm7 2y ago ↗ Lines in 079.l that must not be indented: 24-26,33,36,39,48,57,76,90,106,119,126,134,149,150All other lines must be indented.
[–] 1vuio0pswjnm7 2y ago ↗ Lines in 079.l that must not be indented: 24-26,33,36,39,48,57,76,90,106,119,126,134,149,150All other lines must be indented.
8 comments
[ 3.3 ms ] story [ 27.5 ms ] threadAll other lines must be indented.