Sometime back we discussed a command line based tool youtube-dl that can be used to download youtube videos through command line. In this article, we will discuss another command line tool (a python script) to download youtube videos — PYTUBE.
NOTE – All the examples presented in this article are tested on bash shell in Ubuntu 13.04
A Brief Tutorial
Pytube is a python script that can be used to download youtube videos through command line. This tool can be used to its potential when user runs individual python commands (from the script) one by one. It obviously requires python to be installed on your system.
When you go through the README.md file that comes along with the source code, you will find a complete example that helps you understand how to use this script.
Here is a snapshot of that example :
Read and understand all the print commands carefully as this is where you can decide the details of the video being downloaded. After going through the these steps listed in README.md file, I tried to run the same example again. Here are some snapshots related to that :
First enter in the python environment :
After this, I tried commands one by one :
So you can see that everything was fine until I executed the following command :
So, I referred the example details (shown earlier) and realised that the get() function would require another argument i.e, resolution. I tried 320 and this command worked fine but the download command gave the following error :
So, I changed the resolution in get() function to 720 and tried the download command again.
And as you can see, the video started downloading. You can check the downloaded file in the current working directory, once the command returns.
So, you can see the file named Dancing Scene from Pulp Fiction.mp4 is present in the current directory.
I checked the downloaded file using vlc player and it worked fine.
So this way, you can use this nice little python script to download youtube videos easily.
Here are some important links related to pytube script :
- Home Page
- Use the commands — easy_install pytube or pip pytube – to download this utility. Its source can be downloaded from this Download Link
The download file would be a zip file. You can extract the file from zip file using unzip command, enter into the main directory (pytube-master in my case) and run all the script commands from there.
- Provides all the details so that user can choose the video configuration before downloading it.
- It is a small script, which means that you can easily understand how it functions.
- Requires python environment and a bit of python understanding to run the script and debug the problems.
- The main example is broken — could get difficult for first time users to get started with it.
If you are a command line lover and are into habit of archiving your favourite videos by downloading them from youtube then this utility is for you. Its capability to let the user decide the video configuration is its biggest plus. Try it, it does what it promises.