DEV Community

Cover image for Youtube Video Downloader Application in Python
Trilochan Parida
Trilochan Parida

Posted on

Youtube Video Downloader Application in Python

You need to install pytube package to download youtube videos

pip3 install pytube

Then run below code and your youtube downloader is ready.

from tkinter import *
from pytube import YouTube
import ssl

ssl._create_default_https_context = ssl._create_unverified_context

canv = Tk()
canv.geometry("400x350")
canv.title("Youtube Video Downloader")
Label(canv, text="Welcome to Youtube Downloader!!!").pack()
lvar = StringVar()
lvar.set("Enter the Youtube Video URL")
Label(canv, textvariable=lvar).pack()
url = StringVar()
Entry(canv, textvariable=url, width=30).pack(pady=10)

def download():
    try:
        lvar.set("Downloading...")
        canv.update()
        YouTube(url.get()).streams.first().download()
        lvar.set("Video Downloaded Successfully")
    except Exception as e:
        lvar.set("Error: " + str(e))
        canv.update()

Button(canv, text="Download", command=download).pack()

canv.mainloop()
Enter fullscreen mode Exit fullscreen mode

If any doubt, please comment below.

Watch the full course on Python: https://www.youtube.com/playlist?list=PLpzY0hUPKIeeRj3jOdC2YRD_MfCtBgDEe

Discussion (0)