Skip to content

Instantly share code, notes, and snippets.

@Shivam010
Last active July 28, 2022 19:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shivam010/ef3783638e09eb448d324bf782464b25 to your computer and use it in GitHub Desktop.
Save Shivam010/ef3783638e09eb448d324bf782464b25 to your computer and use it in GitHub Desktop.
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

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