This is just a two-line program but to convert it to GUI YouTube Video Downloader is a bit longer still, this program of GUI YouTube Video Downloader is less than 25 lines.
But still, if you want that two-line program then click here.
We have explained this program in every line to make it understand easily for you.
We have created two entry widgets, one to ask the user to enter the URL or link of a YouTube video and the other to add that link.
Then, we have called the download function using the “Download Video” button.
You can download the pytube module using
"pip install pytube" but if this gives you the error then you should try
"pip install pytube3" inside your terminal.
Now, let’s see the code and understand.
# importing tkinter from tkinter import * # importing YouTube module from pytube import YouTube # initializing tkinter root = Tk() # setting the geometry of the GUI root.geometry("400x350") # setting the title of the GUI root.title("Youtube video downloader application") # defining download function def download(): # using try and except to execute program without errors try: myVar.set("Downloading...") root.update() YouTube(link.get()).streams.first().download() link.set("Video downloaded successfully") except Exception as e: myVar.set("Mistake") root.update() link.set("Enter correct link") # created the Label widget to welcome user Label(root, text="Welcome to youtube\nDownloader Application", font="Consolas 15 bold").pack() # declaring StringVar type variable myVar = StringVar() # setting the default text to myVar myVar.set("Enter the link below") # created the Entry widget to ask user to enter the url Entry(root, textvariable=myVar, width=40).pack(pady=10) # declaring StringVar type variable link = StringVar() # created the Entry widget to get the link Entry(root, textvariable=link, width=40).pack(pady=10) # created and called the download function to download video Button(root, text="Download video", command=download).pack() # running the mainloop root.mainloop()
- The system of the binary conversionThe binary number system defines a number in a binary system. You only find the number in a two-number system the 1 and the 0. The binary number system is an alternative system of representation to the decimal number system. The decimal number system is from (0 to 9) and has a base of 10…
- What is web development for beginners?Introduction In web development, we refer to website so web development refers to website development. “Web” word has been taken from the spider’s web because of the analogy that like a web is connected similarly websites are also connected to each other through the Internet. History of web development 3 Pillars of web development HTML…
- Guide to Proxy Servers: How They Work and Why You Need Them?What is a web proxy? During our college days, we often heard the term “proxy” which referred to the act of someone else marking our attendance, allowing us to be present in a class even if we were not physically there. In the context of the Internet, a web proxy works similarly, acting as an…
- Python | Check Armstrong Number using for loopAn Armstrong number is a number that is equal to the sum of its own digits raised to the power of the number of digits. Consider 153. It has 3 digits, so we raise each digit to the power of 3(the number of digits) and sum them up:1^3 + 5^3 + 3^3 = 1 +…
- Python | Factorial of a number using for loopThe factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. The factorial of 0 is defined to be 1. The factorial formula can be expressed as: n! = 1 * 2 * 3 * … * n Code to calculate factorial of…