YouTube Video Downloader Using Python

YouTube Video Downloader Using Python

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.

Code

# 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()

Output

YouTube Video Downloader Using Python

Also read:

  • Unveiling the Future of AI Detector
    The rise of AI (Artificial Intelligence) content creation tools, especially ChatGPT, Bard, Jasper, etc., has imposed multiple threats to academia and the search engine world. Now, many students and researchers spend less time on research. Instead, they create content from different AI tools, paraphrase them, find a few relevant studies, and submit them as their … Read more
  • CodeWithHarry Earns 20 Lakhs per month from YouTube?
    CodeWithHarry is a YouTube channel owned by Haris Ali Khan, hailing from Rampur, Uttar Pradesh, India. In 2013, he embarked on his academic journey at the Indian Institute of Technology Kharagpur in West Bengal, where he pursued Industrial & Systems Engineering (ISE), a 5-Year Dual Degree Course. He initiated his YouTube channel on 28 April … Read more
  • Cleaning Service Booking System in Python Tkinter
    Introduction Hello friends, in this article we will see a very simple cleaning service booking system in Python tkinter. This project can not be used in the real world, this just tries to mimic real-world online service applications and that’s why the features of this app are limited. In simple words, you can use this … Read more
  • Farmers Ecommerce App using Python Tkinter
    Introduction Hello friends, I will show you how to create a simple e-commerce app for farmers using Python and the tkinter library in this tutorial. Before anything, let me tell you that this is not a real e-commerce app where anyone can list and buy products like we do on Amazon or Flipkart.Technologies used-> Python, … Read more
  • Guidelines for Project Collaboration Process
    Hi, Thanks for contacting Please send complete details about your project. Whatever features/requirements you want in your project/application/software, please write now, changes/updates later will/may not be entertained Necessary – Tell your budget Payments – You will need to pay according to milestones, let me explain. Let us say, there are 5 tasks in your project, … Read more


Share:
Avatar of Harry

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at admin@copyassignment.com Thank you