tech drops

RSS

Posts tagged with "youtube"

Mar 5

Downloading online videos made (hacker-)friendly

This is my favorite way to download YouTube videos (or Vimeo and much more). Here is the initial setup:

  1. Install `youtube-dl` (via homebrew for OS X)
  2. Set up bash aliases such as these:

alias yt1080="youtube-dl -f 37/46 -o '[%(uploader)s] %(title)s.%(ext)s' $1"
alias yt720="youtube-dl -f 22/45 -o '[%(uploader)s] %(title)s.%(ext)s' $1"
alias yt480="youtube-dl -f 44/35/18 -o '[%(uploader)s] %(title)s.%(ext)s' $1"
alias yt360="youtube-dl -f 18/43/34 -o '[%(uploader)s] %(title)s.%(ext)s' $1"

Now whenever you want to download a video, just type yt1080, yt720, yt480 or yt360 (depending on the desired quality) followed by the url of the video (or just video id) to start downloading the video with a nicely formatted filename. The script will select the mp4 version first, falling back to webm or flv, respectively. Example:

$ yt720 fdJc1_IBKJA
[youtube] Setting language
[youtube] fdJc1_IBKJA: Downloading video webpage
[youtube] fdJc1_IBKJA: Downloading video info webpage [youtube] fdJc1_IBKJA: Extracting video information
[download] Destination: [devinsupertramp] World's Most Insane Rope Swing Ever!!! - Canyon Cliff Jump.mp4
[download] 4.0% of 82.25M at 658.52k/s ETA 02:02