youtube-dl under Windows

The following text explains how to run youtube-dl under Microsoft Windows. The first part describes some generic instructions about installing a command line program, followed by specific instructions on running youtube-dl.

Disclaimer

User nishad provides a standalone executable for youtube-dl. With it, you don't need the Python interpreter. In addition, he has created an optional graphical user interface to ease using the program. The following instructions apply if you want to install the official version of youtube-dl with the Python interpreter, and still apply if you want to install the standalone executable. In that case, you can skip the step of installing the Python interpreter.

His contributions can be downloaded from http://www.himili.com/blog/downloads/youtube-video-downloader/. If you use these versions and find a problem, contact him first. He will redirect real youtube-dl issues to me.

Preparing to install a command line program

The Windows command line interpreter is a program called cmd. It can be found somewhere in the applications menu, but many people prefer to run it by clicking on Start > Run and then typing cmd and pressing the enter key. It's very similar to the DOS command line interpreter, if you're old enough to remember it. When you launch it, it will be usually running at your home directory. It's C:\Documents and Settings\<username> usually, where <username> is your user name in that computer, and it will be waiting for you to input commands followed by the enter key. The text to the left of the cursor usually indicates the so-called current working directory, followed by a greater than (>) symbol. You can go up the directory hierarchy with the command cd .., change the current working drive letter by typing its name as a command, like D:, and you can go to a subdirectory (or subfolder, as Windows prefers to call it) by typing the command cd followed by its path, maybe using double quotes if the name contains spaces, like in cd "My Documents\My Porn\My Hardcore Orgies\Animals". Just kidding. The cd command stands for change [to] directory.

The goal here is to use youtube-dl.py as one of those system commands. The problem is that youtube-dl.py is a simple text file you will download from a webserver and will be stored in some obscure place in your hard drive. If you want to type youtube-dl.py in the command line interpreter and have it run the program, you will have to give the command line interpreter at least a clue about where to find the program, or it will find youtube-dl.py to be a meaningless name.

This is where the PATH environment variable is important. Environment variables are pairs of names and values that are available to any program that is running on the computer. This environment variable is specially useful for the command line interpreter, as its value is a list of folders where system commands and programs can be found. So what we will do is to create a personal folder where we can drop command line programs, and add that folder to the list of folders in the PATH environment variable.

So let's go to our home directory. Our home directory or folder is the one that contains folders such as My Documents or the Desktop folder. However, for some reason, Microsoft didn't make it simple to reach that directory. One would expect that going to the My Documents folder and going up one level, you'd reach the home directory, but that's not the case. The Windows explorer will take you to a different place if you go up from the My Documents folder. One straightforward way of going there is to click on Start > Run and typing explorer "%USERPROFILE%" literally, followed by the enter key. Once there, right click on an empty space and choose to create a new folder, giving it an appropriate name like Commands or something similar. Double click to enter the newly created folder, and don't close that explorer window yet.

Now click with the right mouse button on any My Computer icon, and choose Properties. There should be an Advanced Options tab, which has a Environment Variables button at the bottom, which you have to press. In the window that will be opened you can set your user or personal environment variables, and the system environment variables if you have enough security privileges. Modifying the personal environment variables will be enough for our case.

First, check to see if you have a PATH environment variable among your personal variables. Usually, you won't have it, so you'll have to create a new variable, with the name PATH, and use %USERPROFILE%\Commands, literally, as the variable value. Be careful when typing that and don't forget to change the word Commands to the appropriate name if you didn't use that name when creating the folder. In the case a PATH environment variable already exists, it should contain one or more directories or folders, separated by semicolon characters. In that case, simply append ;%USERPROFILE%\Commands at the end. Note the semicolon character used as a separator. It's also a good idea to create a personal variable named HOME with the value %USERPROFILE% at this moment. Finally, accept all the changes. Programs started from now on will have the new folder in the PATH environment variable.

Up to this point, we have created a Commands folder where we can drop command line programs and later use them in the command line interpreter, because the interpreter will be able to find them. These steps were all generic, and you can drop any command line program in there. In the next step, we'll drop youtube-dl.py in it.

Running youtube-dl.py

If the Python interpreter is not installed in your system, install it now. There is a download section in the previous webpage that lets you download a Windows installer to run Python programs. Remember you have to get version 2.x, with x being at least 4.

Now go to the youtube-dl webpage and download the program to your Windows Desktop. Under Windows, it's important that you use the .py suffix in the program name, so be sure to set it when downloading, or at least rename it after the download.

Right click on it and select Cut. Go to the explorer Window we left open previously, right click on an emtpy space and choose Paste. Tadah! Installation finished.

Now let's suppose I want to download a video to my Windows Desktop. Piece of cake: go to Start > Run, type cmd and press the enter key. Type the command cd desktop and then type the command youtube-dl.py "", where is a YouTube video URL you can copy from your web browser program address bar, and paste it to the command line interpreter window by right clicking and choosing Paste, for example. Remember commands are always followed by pressing the enter key in the command line interpreter.

One final tip

If you are going to store all your videos in a fixed folder, some people find it handy to create a shortcut to cmd that starts with the current working directory set to that folder, so as to avoid typing a cd command each time they launch cmd. To do this, right click on an empty space in your Desktop and choose to create a new shortcut. The program you want to launch is cmd and you can give the shortcut any name you want. After it's created, right click on it, choose Properties and, in the Shortcut tab, which should be the one selected by default, there's an option called Start in:. Put something like %USERPROFILE%\Desktop or %USERPROFILE%\My Documents in it. Some people also prefer to put that shortcut in the quickstart bar to the right of the Start button. Whatever floats your boat.

Conclusions

The hardest part is preparing the Windows system to run user command line programs, as it's not initially prepared to do that. Linux, MacOSX and other systems are, in my humble opinion, better prepared, out of the box, for downloading and running your own command line programs easily.

A remaining question is how to play those videos. You'll need a video player capable of playing FLV videos. I know a couple of them, but you should better ask a Windows expert about it. At least the video files will be in your hard drive, so sooner or later you'll be able to play them.

Good luck!