Skip to content

Instantly share code, notes, and snippets.

@Shivam010
Last active Jul 28, 2022
Embed
What would you like to do?
Download Youtube Playlist or Videos as Audio or videos

Download Youtube Playlist or Videos

# Download a single video
youtube-dl -o '%(title)s.%(ext)s' "https://www.youtube.com/watch?v=R1Pmcy74Kfs"

# Download whole playlist in a separate directory with videos indexed as the original order in playlist
youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' "https://www.youtube.com/playlist?list=PLkn0zold0m0gPVxbke9slzodvPt6wSRob"

# If only want audio files of the videos
# Instead of using `youtube-dl` use `youtube-dl -x` in above commands 
# by default it will convert video into its best quality audio file
# and If you want it in particular format use `youtube -x --audio-format mp3`

# Just replace the links with the video or playlist you want to download
@Shivam010
Copy link
Author

Shivam010 commented Apr 26, 2022

# Download only audio
youtube-dl -x --audio-format m4a -o '%(title)s.%(ext)s' "https://www.youtube.com/watch?v=R1Pmcy74Kfs"

@Shivam010
Copy link
Author

Shivam010 commented Jul 28, 2022

Also to add the metadata from Youtube to the videos add this option --add-metadata
Hence, to download only audios with metadata use:

# Download only audio
youtube-dl --add-metadata -x --audio-format m4a -o '%(title)s.%(ext)s' "https://www.youtube.com/watch?v=R1Pmcy74Kfs"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment