Are you a Python programmer and looking ahead to explore more Python codes and build something interesting? Look no further as i have made a special tutorial on making your own Youtube Downloader using Python Programming language and pytube Library.
We start by installing an external library called pytube. This has all the function inbuilt that we will need to build up the downloader.
Fire up command prompt (or terminal if you are on linux or mac) and type the following command:
Now we are all set to write some code. Fire up your favourite text editor.
We will start by importing pytube that we just downloaded.
We will take the link of youtube as input to our program
Python Youtube Downloader
We will create a pytube.YouTube object which takes link to video as constructor. and then we will register a callback function which will be called everytime a byte of video is downloaded to disk. Here, we are just printing the percentage of file downloaded. You can create a progress bar ro show download progress.
yt = pytube.YouTube(link)
There are two type of format available for us to download, progressive and adaptive. we can use filter to separate progressive videos or we can choose to download adaptive video and stitch audio and together ourselves. For the sake of simplicity of the tutorial, we will filter out progressive video format to avoid extra work.
for i in range(len(vids)):
Voila! The video is downloaded at the current location of the python script.