Skip to content

Instantly share code, notes, and snippets.

@daltonbr
Last active November 6, 2020 04:27
Show Gist options
  • Save daltonbr/aec12a3cad41a0baf4327069eafdbf56 to your computer and use it in GitHub Desktop.
Save daltonbr/aec12a3cad41a0baf4327069eafdbf56 to your computer and use it in GitHub Desktop.
CLI 'youtube-dl' examples, how to easily download youtube videos
# brew install youtube-dl (on mac)
# https://github.com/rg3/youtube-dl
# alias
alias cd..="cd .."
alias sync="adb push --sync ~/Movies/*.mp4 mnt/sdcard/Movies/"
alias yt="youtube-dl -o '~/Movies/[%(release_date)s]-[%(id)s].%(title)s.%(ext)s' --restrict-filenames"
alias ytplaylist="youtube-dl -o '~/Movies/%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s'"
alias mp3="youtube-dl --extract-audio --format bestaudio --audio-format mp3 --prefer-ffmpeg --audio-quality 160K --output '%(title)s.%(ext)s'"
alias mp3playlist="youtube-dl --ignore-errors --format bestaudio --prefer-ffmpeg --extract-audio --audio-format mp3 --audio-quality 160K --output '%(playlist)s/[%(playlist_index)s] - %(title)s.%(ext)s' --yes-playlist"
$ youtube-dl --get-filename -o '%(title)s.%(ext)s' BaW_jenozKc
youtube-dl test video ''_ä↭𝕐.mp4 # All kinds of weird characters
$ youtube-dl --get-filename -o '%(title)s.%(ext)s' BaW_jenozKc --restrict-filenames
youtube-dl_test_video_.mp4 # A simple file name
# Download YouTube playlist videos in separate directory indexed by video order in a playlist
$ youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re
# Download all playlists of YouTube channel/user keeping each playlist in separate directory:
$ youtube-dl -o '%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/user/TheLinuxFoundation/playlists
# Download Udemy course keeping each chapter in separate directory under MyVideos directory in your home
$ youtube-dl -u user -p password -o '~/MyVideos/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s' https://www.udemy.com/java-tutorial/
# Download entire series season keeping each series and each season in separate directory under C:/MyVideos
$ youtube-dl -o "C:/MyVideos/%(series)s/%(season_number)s - %(season)s/%(episode_number)s - %(episode)s.%(ext)s" https://videomore.ru/kino_v_detalayah/5_sezon/367617
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment