Youtube-dl, download Youtube videos on the Mac

By Devin Prater, 26 April, 2018

Youtube-dl, download any Youtube video or videos on the Mac for free

In this guide, I’ll be showing you how to use Youtube-dl, the Youtube-downloader, to download a single video, multiple videos, and how to customize Youtube-dl.

Introduction

Youtube-dl is a free tool which is run from the terminal, but I’ll try to make the mysterious Terminal as friendly as possible. First, let’s gather the software we need.

Homebrew: the Terminal’s App store

Homebrew, found at this site is a "Package manager" which essentially means that it is an app store. Linux lovers may feel disdain for such a term describing a package manager, but this post isn’t for those who are natives to the Terminal, or "console." This post is for those who are Mac users, comfortable with beautiful interfaces that just work. So, let’s get to it. First, find the Terminal app, in the Utilities folder of Finder. and open it. You should hear plenty of gibberish from VoiceOver, ending with your username, then a dollar sign. This means that Terminal is prompting you for a command. Commands are simply program names, like "cp" for copying files, "rm" for deleting files, and "nano" for editing simple text. All these programs are commands, and you just type them in to run them. Many commands have "arguments" or options which can be typed after the command name. For example, if you have a file named test.txt, you can type nano test.txt to open it. Now, we know how to run things, so let’s install an app store! Go to the Homebrew site, and find the command to return into the Terminal. It Will start with /usr/bin/ruby. Copy that whole line to the clipboard, and paste it into Terminal, and press return if necessary. You’ll know if you need to press return if nothing happens. VoiceOver will automatically read what’s happening as the program runs. The installer will download Homebrew, and install it for you. Now, you have the brew program you can use, you’ve leveled up!

Using Homebrew

Now that you have Homebrew installed, you can use the brew command to manage your packages, or "apps" if you prefer. If you need help with Homebrew, and you search the Internet, the proper term is "package" not "app," but I said I’d make this guide friendly. Now, let’s see how to install something. brew install youtube-dl This command installs the youtube-dl program, which is what you came here to learn about. let’s take this command apart to see what all it does. brew: This is the Homebrew program. Brew is the name of the program, shortened because most people like typing as little as necessary to get commands to run. install: This instructs the brew program on what we want it to do. youtube-dl: This is what we want it to install. Brew will download the package, and run its installer, just like the app store. Now, type the above command into the Terminal, with spaces between each word. If you mess up, nothing will break, Brew will just tell you that something was wrong with what you wrote. Now, brew should be installing youtube-dl. You’ll know when its done when you hear your username, and the dollar sign again. If not, try running brew install youtube-dl again. If you must, copy and paste the command, although typing it out is recommended so that you get used to writing commands.

From time to time, packages may be updated. To get updates, run brew upgrade Youtube-dl makes updates at least once a month, and sometimes weekly, or even daily.

a little more about the Terminal

Let’s talk about folders now. When you download videos, you’ll want to put them into a certain place, right? And moving them manually from the Finder would be a pain, right? Well, maybe you’d like the arduous work of moving things from Finder, but I don’t. So, we’ll learn how to move through folders, or "directories."

Commands:

  • cd: Change directory
  • ls: list
  • cp: copy
  • rm: remove
  • mkdir: Make directory

Here, we have some of the most important basic Terminal commands. Practice them frequently, and you’ll be able to move around directories, and keep things more organized.

Putting youtube-dl to some use

Now, we’re ready to download a video, finally. Find a video on Youtube that you’d like to download, and copy its address. To do this, press Command + L, then Command + A, then Command + C. Open the Terminal, and type youtube-dl then press the Space bar, then command + V, and return. Now, the video starts downloading, within the current directory. You’ve now downloaded your first video. But what about just audio? With the same video link in the clipboard, open the Terminal and type youtube-dl as before, but this time after pressing space, type -x --audio-format mp3 then paste the URL and press return. This tells youtube-dl to extract the audio from the video, then convert it to mp3. Now, you have all this to type: youtube-dl -x –audio-format mp3 http://www.youtube.com A bit much, right?

If the download doesn't work for some reason, and the Youtube address has an ampersand character in it, enclose the address in quotes.

configuring youtube-dl

Imagine having to set up a program each time you run it. Sure, typing commands isn’t as hard as navigating screens with VoiceOver, but it can still be a lot to remember. That’s what configuration files are for. They allow one to set options for a program and forget it. Youtube-dl can use a configuration file, as well. You’ll have to make it, but that’s not too hard mkdir ~/.config/youtube-dl/ touch ~/.config/youtube-dl/config Now, you can open the configuration file in your favorite editor, I use Emacs, so: emacs ~/.config/youtube-dl/config You can substitute Emacs with any other editor you like: Nano, Vim, and so on. Here, you write the arguments that you normally would write before the Youtube address. Write the following into the file: -x –audio-format mp3 Then, with Emacs, press Control + X, then Control + S, then Control + X, then Control + C to save the file, and exit Emacs. There, now you only have to go to the Terminal and type youtube-dl then paste the address. Another good use for the configuration file is to sign into Youtube as well. put this into the file: -u username -p password Replace username with your Youtube email address, and password with the account password. All of these "arguments" should be on one line: -x –audio-format mp3 -u username -p password Now, when you download a video, it may count as a view for the video so that the creator gets more views, and you get a good, accessible MP3 file.

Searching Youtube

There is a way to search Youtube, and download the results, right from Youtube-dl. youtube-dl "gvsearch15:search terms" This searches Youtube for "search term" and downloads the first 15 results. Change this to your liking, and practice often to get better at typing this command, and understanding how it works. Notice that there is a quote sign before gvsearch, and after the last search term, and a colon before the first search term.

Conclusion

This guide is a great start for those who want to download Youtube videos from a Mac, for free, and with guaranteed accessibility. The learning curve may be more steep than most Mac software, but it is well-worth the time and effort you put into it.

Disclaimer

The article on this page has generously been submitted by a member of the AppleVis community. As AppleVis is a community-powered website, we make no guarantee, either express or implied, of the accuracy or completeness of the information.

Options

Comments

By Piotr Machacz on Tuesday, April 24, 2018 - 09:46

Youtube-dl is a great program. One thing that's definitely worth mentioning is that it can be used not just for downloading from YouTube, but also from many, many other video and audio sites. It can also, for example, download any track, even ones that have downloads turned off, from SoundCloud. You can also download multiple videos/tracks at once. If you paste in a URL to a playlist of videos or the link to a Channel on YouTube, or SoundCloud for that matter, youtube-dl will be more than happy to download all videos/songs it contains. Here is a page describing every command and site supported, which let you do things like ignore errors, set up a proxy, limit download speed or configure how the files are named. This will be a useful reference when setting up your configuration.
https://github.com/rg3/youtube-dl/blob/master/README.md

By Kyle on Tuesday, April 24, 2018 - 09:46

also the comment must be made since homebrew is a full and complete package manager you need to keep it up to date.
brew update
brew upgrade
will do the trick if you run it every week or so.

By Callum Stoneman on Thursday, May 24, 2018 - 09:46

Hi,

This guide is great, however the link from which Homebrew is available doesn't work, at least for me. Safari simply says it cannot find the server.

By Devin Prater on Thursday, May 24, 2018 - 09:46

In reply to by Callum Stoneman

Thanks so much. This has been updated.

By falcon wings on Thursday, May 24, 2018 - 09:46

Sorry about the OT question, but...
Is there a similar app on IOS that could do such a thing? that is download videos from many places?
just like youtube dl.
Security options would be neat to have but are not mendatory.
I would take any free apps with adds,but if there are none I would take a payed recommendation just as well...

By Callum Stoneman on Thursday, May 24, 2018 - 09:46

Hi,

I just got round to trying this out properly. I'm trying to convert a video to an MP3 file using the commands you provided but it doesn't seem to be working. Here is what I'm typing:

youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=d07vmvuZtvY

That URL is the video I'm trying to convert. Once I enter that command and press return, VoiceOver announces "Downloading webpage", followed by "Downloading video info webpage", followed by what seem to be a random bunch of numbers every few seconds, then it says something not installed, please install one then returns me back to the standard terminal prompt. This "something" sounds like "RR Prober" but I could be wrong.

A file did download in the directory I specified, but it was not an MP3 file.

Any ideas? I have already tried entering the URL in quotes and got the same result.

Try interacting with the text area, and using VOICEOVER+up arrow to see what to install, then do brew install with that. For example, if it wants ffmpeg, do
brew install ffmpeg
that's only a guess, though. You can also use voiceover+shift+left or right arrow to read by character when navigating within text fields that don't support actual arrow navigation.

By Callum Stoneman on Thursday, May 24, 2018 - 09:46

Hi,

Thanks for your reply. I have navigated the output by character and it says "ffprobe or avprobe not found. Please install one." Brew install ffprobe and brew install avprobe both result in errors.

By Piotr Machacz on Thursday, May 24, 2018 - 09:46

ffprobe is a part of ffmpeg, so that's what you need to install.

brew install ffmpeg should do it. That's f f m p e g.

By Callum Stoneman on Thursday, May 24, 2018 - 09:46

In reply to by Piotr Machacz

Thanks so much. I installed fmpeg and it's working brilliantly now.

Thanks again.

By Sam Doman on Monday, June 24, 2019 - 09:46

Hi. So I installed the program and did everything that was mentioned in the guide, but whenever I convert something to mp3, it says extraction error. I installed FFmpeg, So I'm not sure what's up.

By Carla Rogers on Thursday, December 24, 2020 - 09:46

Please correct me if I am wrong, it seems established now that youtube-dl no longer downloads from youtube. It had been working without a hitch, but a few weeks ago, kaput.

So I am wondering, how is the app Any Video Converter able to pull it off? If the app can do it, there must be a way to do it using basic utilities like youtube-dl.

Is there another command line solution for downloading videos from YouTube?

By KE7ZUM on Thursday, December 24, 2020 - 09:46

You can also eliminate the ID from the video as well. I forgot how to do it but I'll look in my .bash_profile as I created an alias to do this.

By Callum Stoneman on Thursday, December 24, 2020 - 09:46

YouTube-dl was briefly removed from GitHub due to a DMCA takedown notice, which is why it stopped working. The developer(s) released a patch that seems to address the issues raised by the DMCA notice and the program is now available again. This post from the GitHub Blog contains more information. To get it working again, you simply need to perform an update by running "youtube-dl -U". You may need to add "sudo" to the start of that command.

I heard about that, and github took a stanse against the take down. I'm on windows so not sure if I can do sudo, but I"ll figure it out.

By KE7ZUM on Thursday, December 24, 2020 - 09:46

Yep, did that a few weeks ago. I also update via apt-get anyway on mac, so I don't need to worry much.

By Brad on Thursday, December 24, 2020 - 09:46

Once I had my batch files set up; and ffmpeg installed, everything worked fine, it's as simple as coppying a URL, putting it into the batch file, running it and sitting back and relaxing.

I wonder if I could make things even easier for me...

I have 2 batch files, one for playlists and one for only single videos.

I wonder if I can make them into one kind of program and make it so, if you press 1 it takes you to the convert only 1 video part and 2 for playlists? Along with a message letting me paste my url into the command line box?

I think it's doable; I just have no idea how.

By Sam Doman on Sunday, January 24, 2021 - 09:46

Hi, Whenever I try to download a url and convert it to audio with the instructions presented here, I've been getting a no matches found mesage for some reason.
Thanks.

By KE7ZUM on Sunday, January 24, 2021 - 09:46

try youtube-dl -f audio then the URL

I think I have that syntax right. I have to do that for the video from facebook

youtube-dl -f Best

Good luck.

By jim pickens on Monday, January 24, 2022 - 09:46

A faster alternative is, YT-DLP

By Unregistered User (not verified) on Monday, January 24, 2022 - 09:46

Simply use pyyoutube python module and download not only video and also audio.

By wheelysneakycat on Saturday, September 24, 2022 - 09:46

Hi,

I've never used terminal before and followed the instructions here to install homebrew. I'm not sure whether it has installed or not but I don't think it has. Eventually after VoiceOver stopped reading lots of stuff I thought the last thing it said was something about needing something but I couldn't hear it properly. And I can't work out how to review the text. Then I interacted with the text and got to what I think is the bottom where it seemed to be asking for my password which I typed in and now it says it's looking for updates. So I will look at it again later but in the meantime please does anyone have some sort of guide about how to actually use terminal? Like how to read the last line of text which appeared? Or any other useful information just about how to use terminal?