News for hackers. Stuff that matters.
Re:APL Style: Patterns/Anti-patterns by feelin_googley on Sunday March 04, 2018 @05:57PM (#16517322)
For those who do not use Javascript in the browser, here is another source of the presentation:

https://www.youtube.com/watch?v=9xCJ3BCIudI

Lots of good commentary not in the slides.

And here is a way to download the video without Javascript. I have been meaning to try to rewrite this in k.

     #  Notes
     #  Works by brute force and has been reliable for years
     #  Was easily updated when YouTube made changes (rare)
     #  Zero dependencies except tr, sed and an https client
     #  Takes a YouTube URL on stdin  
     #  Example usage: 
     #  echo http://www.youtube.com/watch?v=9xCJ3BCIudI|ytd 22 file
     #  "ytd" is name of the script
     #  "22" is itag-no in this case large mp4 ("18" is smaller mp4) 
     #  "file" is optional filename, no extension required
     #  if no filename given video is saved as "1.mp4"
     #  UNIX-like: url-filter < file-containing-url|ytd 22 
     #  Caution when copying and pasting: line 2 needs to retain the 4 space indent
     #  N.B. Will not work with restricted videos; *this is not for downloading music or other commercial crap*; use youtube-download if thats what you are after
     #  N.B. Some videos may require a few tries, most will work on the first try; if get 403 try again
      
    #!/bin/sh 
    case $# in [123]);;*)exec echo usage: $0 itag-no \[file\];esac;a=$(exec sed 's/http:/https:/;s/m.youtube/www.youtube/;s/youtu.be./www.youtube.com\/watch?v=/;s/hooktube.com/youtube.com/;s/embed./watch?v=/;#etc.;s/?version.*//;s/;.*//'); n=0;while true;do b=$(curl $a|exec tr -cd '\12\40-\176'|exec sed 's/https%3A/\
        &/g;s/ *//;/   https%3A%2F%2F/!d;s/%3A/:/g;s/%2C/,/g;s/%2F/\//g;s/%3D/=/g; s/%3B/;/g;s/%3F/?/g;s/%26/\&/g;s/\\u0026/\&/g;s/%252C/,/g;s/%252F/\//g;s/%22/\"/g; s/%255B/[/g;s/%255D/]/g;'|exec sed '/itag='"$1"'/!d;/video.mp4/!d;/webm/d;/ytplayer/d;s/;+codecs.*//;s/&xtags.*//;/timedtext/d;s/&itag=..//2');test ${#b} = 0||break;test $n -le 9||exit;n=$((n+1));done;case $1 in 18|22)ext=mp4;esac;exec echo curl $3 -4o ${2-1}.$ext $b;
Re:APL Style: Patterns/Anti-patterns by feelin_googley on Tuesday March 06, 2018 @01:39PM (#16530896)
Corrections: 1. remove "echo" from line #2; 2. add " -v" after "curl" in line #2 so one can see occasional 403 errors.