Installing YouTube-DL on Windows Subsystem for Linux (WSL)

Please read my previous post on how to enable Windows Subsystem for Linux (WSL) on Windows 10.  You must have the Windows 10 anniversary update installed since WSL is not available on the original Windows 10.

Youtube-dl is an awesome downloader for multimedia from the internet using a simple command line.  You can encode the video into a different format as well (namely FLV and MP4).

Since Windows System for Linux doesn’t automatically install Python which is required for Youtub-dl to work correctly, you need to first install Python.  You can install either Python 2.7x or Python 3.x.  I installed Python 2.7x since most libraries are more compatible with it.  To install Python 2.7x, open up your Ubuntu Bash window, and type in this command:

sudo apt-get install python

If you are adventurous and want to try Python 3, then use this command:

sudo apt-get install python3

In the past when I tried having both versions, there are conflicts when trying to run Python codes. So I just pick one version and stick with it. I recommend using 2.7x for stability and comparability. Eventually Python 3 will be the best version but maybe give it a couple more years.

There are many ways to install youtube-dl, here are the 2 common ways:

Using apt-get
Open up your Ubuntu Bash window, and type in this command:

sudo apt-get install youtube-dl

After the installation is done, run an update

sudo youtube-dl -U

Using Pip
First you have to install Pip

sudo apt-get install python-pip python-dev build-essential 
sudo pip install --upgrade pip 
sudo pip install --upgrade virtualenv 

Now you can install youtube-dl with pip using this command:

sudo pip install youtube_dl

Then upgrade with Pip

sudo pip install --upgrade youtube_dl

If you try to do a video download (Master of the House song from Le Miserable) from youtube, you’ll get a bunch of errors.

sudo youtube-dl -o LeMiserableMasterHouse.MP4 "https://youtu.be/TWlzFbmZZHU"

From searching the web, I found that we need to do a bunch of permission settings to get the downloader to not error out due to things like Protocol error and such. Use this command first:

sudo curl -L https://yt-dl.org/latest/youtube-dl -o /usr/local/bin/youtube-dl

Then set permissions:

sudo chmod a+rx /usr/local/bin/youtube-dl

Now you shouldn’t have problem downloading videos from youtube. The video is downloaded to the directory where you issues the youteb-dl command. You can supply the extension of the file to be .FLV or .MP4 when downloading.

For more details on the commands and options for youtube-dl, please visit this URL:

https://github.com/rg3/youtube-dl/blob/master/README.md#readme

Enjoy downloading YouTube videos!

Enabling Ubuntu Bash on Windows 10

A quick reminder that this feature is only available on Windows 10 (with the latest update). It’s still a beta feature but the developers have fixed many of the bugs and it’s pretty stable.  Hopefully more features will show up in the future to allow us to run more functions closer to the real Ubuntu.

Click the Start button and type in the search “For Developer Settings”.
Choose “Developer mode”.  Windows might prompt for a permission.  Allow it to proceed.

developer settings

Again, click on the Start Button, type into the search “Turn windows features on or off”
search turn windows feature on

Windows Features screen will show up.  Scroll down to find “Windows Subsystem for Linux (Beta)” option and check it.

enable subsystem

Click OK.  Windows will ask to re-boot.  Go ahead and reboot your system.

After computer restarted, click on the Start button and type in search “bash”.  Select bash.exe from the search result and run it.

A command prompt like window will appear.  It’ll ask you to type “y” to proceed.  Type in “y” and wait for the download of the Ubuntu to proceed.

Ubuntu download

Once the install is done, go back to the Start button and type in search “Bash on Ubuntu”. You can pin the program to the task bar or start menu for a later easy access.

start menu

My start Menu looks different from the standard Windows 10 start menu because I prefer Windows 7 style menu.  I highly recommend Start10.  It’s a paid app for $4.99 but I think it’s worth it.  https://www.stardock.com/products/start10/

There are other ways to customize the start menu bar using free software but it’s a topic for a different blog post.

Now that you have Ubuntu Bash install, you can use it just like a normal Ubuntu terminal.  Most of the commands work as long as it’s not server or graphical related functions.  The best thing I found is the use of grep which Windows needed badly and now we have it!

Bash on windows

Another awesome use is installing Go on here.  You could do Go on Windows already, but this moves it closer to the Go programming as it was intended.

A good thing to do is to run the update so that this is up-to-date. Use -y so that it says yes to everything or you can leave it out and individually confirm each download:

sudo apt-get update -y