Preamble
Youtube-dl is a wonderful tool to procure media from Youtube. You can retrieve video and audio in the formats of your choice.
First, check which format available
1 2 3 |
youtube-dl -F url-of-interest youtune-dl -f 14 url-of-interest |
Download from a playlist
1 2 |
youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" <url to playlist> |
Download videos from video-listing text file
Adopted from here.
-
create your batchlist.txt file:
1234https://www.youtube.com/watch?v=A3Et0yeA7P0 # 1:22 Pizza in Naples, Italy - spinning around the worldhttps://www.youtube.com/watch?v=VIJlRXMfW50 # 2:26 How To Hand Toss Pizza Doughhttps://www.youtube.com/watch?v=yfpgDo7uyMo # 3:27 Tony's Pizza - Napoletana Pizza - San Francisco -
enter the youtube-dl script (below) when ready to download videos
example usage:
12youtube-dl -c --title -f best --batch-file batchlist.txtwhere
12345678910111213-f best -- this will give you the 'best' format of the video.# -- is a comment. it, along with any text after it, is igored. i like to comment things, and add duration, etc.optional commands:-c -- Force resume of partially downloaded files.-t or --title -- i like to include the title and description (and sometimes subs) during the YT download.--write-description -- for description of video.--write-thumbnail -- for the thumbnails images.--write-sub -- download the subtitle during the YT download.debugging commands:--simulate -- add this, if you want to test your script w/out actually downloading anything.
Download youtube videos of the best quality audio mp3 using youtube-dl
Adopted from here.
1 2 3 |
youtube-dl -f bestaudio --audio-quality 0 --audio-format mp3 https://www.youtube.com/playlist?list=PLYRruMbyFRcBVdVN8v4FNkIKkXvL-bZn_ youtube-dl --extract-audio --audio-format mp3 --audio-quality 0 <Video-URL> |
Download videos as mp4 instead of mkv (in some case)
1 2 |
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' url |
Tailor it to your need with an alias
1 2 3 |
alias yt='youtube-dl --restrict-filenames --write-thumbnail -o "~/Videos/%(title)s.%(ext)s" -f mp4' alias ytaudio='youtube-dl --restrict-filenames --extract-audio --audio-format=mp3 --audio-quality=320k -o "~/Audio/%(title)s.%(ext)s"' |
16
SEP
SEP
About the Author:
Beyond 8 hours - Computer, Sports, Family...