Python is a high-level general-purpose programming language which is used for various applications. Using python you can make a web application, desktop application, Games, etc. In this python project, we will discuss how to download youtube videos using python and also we will create a nice UI using the Tkinter library.
Youtube is a widely used video-sharing platform downloading a video from youtube is a hectic task. To download a video you need to copy and paste the link to another site or you need to install an extension which will display unwanted ads. To avoid all the headaches and also to develop your programming skill I will show you how to download a youtube video.
Python Kit will be shipped to you and you can learn and build using tutorials. You can start for free today!
2. Machine Learning (Career Building Course)
4. Fraud Detection using Machine Learning
5. Machine Learning using Python
6. Movie Recommendation using ML
7. 3 Computer Vision Projects (Combo Course)
8. Computer Vision - Text Scanner
9. Computer Vision Based Mouse
10. Handwritten Digits Recognition using ML
11. Computer Vision Based Smart Selfie
Let’s get started.
First, download and install the latest version of Python 3 in your computer or laptop. We are going to use “pytube” which is a python library. Python libraries make the programming task easier which allows you to access the program which is already implemented to save lots of time. It is a collection of functions and methods which allows you to code fast. Pytube is a very useful dependency-free library used to download videos from the web.
The best way to install the library is by using pip. PIP refers to Preferred Installer Program which is used to install additional libraries and packages easily using the command line. PIP comes pre-installed with Python 3.4 or greater versions. If you don’t have pip installed, you can download and install pip from this site (https://www.knowledgehut.com/blog/programming/what-is-pip-in-python).
To check the version of pip installed in your computer, open command prompt and type the following command - pip --version then press enter.
Let’s begin the project
import tkinter as tk #importing tkinter library
from pytube import YouTube #importing the pytube library
def downloadVid():
global E1
string=E1.get()
yt= YouTube(str(string))
videos = yt.get_videos() #this will return a list to choose the video quality
s=1
for v in videos:
print(st(s)+’.’+str(v))
s+=1
n=int(input(“Enter your choice”))
vid = videos[n-1]
destination=str(input(“Enter your destination”))
vid.download(destination)
print(yt.filename+”\n is downloaded”)
Want to develop practical skills on Python? Checkout our latest projects and start learning for free
root=tk.Tk() #initializing root component
w=tk.Label(root,text=”Youtube Downloader”) #widget creation
w.pack()
#entry box is created to past the link
E1=tk.Entry(root,bd=5)
E1.pack(side=tk1.TOP) #it is organized using pack function
#Button is created so the program is triggered when it is pressed
button=tk.Button(root,text=”Download”.fg=”red”,command=downloadVid )
button.pack(side=tk.BOTTOM)
#When the button is clicked whatever the function inside the command will be executed in our case the command is to download the youtube video.
root.mainloop()
Now you can run the program and it will start the application and asks you to put the URL in the box. Copy and paste the URL then it will ask you to choose the video quality and give the download location for the video to be saved. Now you can able to see the video is downloaded.
Skyfi Labs helps students learn practical skills by building real-world projects.
You can enrol with friends and receive kits at your doorstep
You can learn from experts, build working projects, showcase skills to the world and grab the best jobs.
Get started today!
Join 250,000+ students from 36+ countries & develop practical skills by building projects
Get kits shipped in 24 hours. Build using online tutorials.
Stay up-to-date and build projects on latest technologies