How to download youtube videos using open source software
UPDATE (April 7, 2024)
The method below stopped working for me sometime in 2023, here is a working solution I currently use:
You will need homebrew installed. See https://brew.sh/ for instructions on installing Homebrew.
Install the yt-dlp
homebrew package from https://formulae.brew.sh/formula/yt-dlp
Example usage:
yt-dlp --extract-audio --audio-format mp3 https://www.youtube.com/watch\?v\=<your-video-id>
See https://github.com/yt-dlp/yt-dlp for additional options.
_________________________________
If you’ve tried to download youtube videos while trying not to download malware, this is for you.
Prerequisites
You will need to have Docker installed, and know if your terminal uses bash or zsh.
All you have to do is use this incantation
alias yt-dl='docker run \
--rm -i \
-e PGID=$(id -g) \
-e PUID=$(id -u) \
-v "$(pwd)":/workdir:rw \
mikenye/youtube-dl'
Add 👆this to your ~/.bash_aliases file or ~/.bashrc or ~/.zshrc file.
Once you’ve done that (and used source ~/.zshrc
, or whatever the name of your rc file you updated) you can download videos by using yt-dl <youtube-url>
Further reading: https://hub.docker.com/r/mikenye/youtube-dl#quick-start
Disclaimer: this might work for apple and linux devices only. Post a comment if you need help.
Also, we’re using docker here so we don’t run into any problems in terms of yt-download not being compatible with your machine (this is what happened with me).
Example usage:
yt-dl --extract-audio --audio-format mp3 https://www.youtube.com/watch?v=KvknOXGPzCQ