Skip to content

Instantly share code, notes, and snippets.

@anwas
Last active April 14, 2025 16:00
Show Gist options
  • Select an option

  • Save anwas/d651f791534f4e3f4502fec835dd6191 to your computer and use it in GitHub Desktop.

Select an option

Save anwas/d651f791534f4e3f4502fec835dd6191 to your computer and use it in GitHub Desktop.
[youtube-dl cli templates] #youtube-dl #youtube #cli
https://github.com/rg3/youtube-dl/blob/master/README.md#output-template
youtube-dl --download-archive archive.txt --output "%(playlist_index)s - %(title)s – [%(alt_title)s].%(ext)s" https://www.youtube.com/playlist?list=PL4dWJMOQ_a1TgayrpaB-SEVJhHC58U1wU --ignore-errors
youtube-dl --download-archive archive.txt -f bestvideo+bestaudio --merge-output-format mkv --output "%(playlist_uploader)s – %(playlist)s/%(playlist_index)s - %(title)s.%(ext)s" https://www.youtube.com/playlist?list=$1 --ignore-errors
youtube-dl --download-archive archive.txt -f 'bestvideo[height>=720]+bestaudio' --merge-output-format mkv --output "%(playlist_uploader)s – %(playlist)s/%(playlist_index)s - %(title)s.%(ext)s" https://www.youtube.com/playlist?list=$1 --ignore-errors
Output template examples
Note that on Windows you may need to use double quotes instead of single.
$ 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
# Stream the video being downloaded to stdout
$ youtube-dl -o - BaW_jenozKc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment