python youtube video downloader

python youtube video downloader

We're going to use tkinter and pytube for this our project

Tkinter is Python's de-facto standard GUI (Graphical User Interface) package

pytube is a very serious, lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos.

let's install pytube

pip install pytube

then our codes.

import tkinter
from pytube import YouTube

#Our project view using the tkinter
root = tkinter.Tk()
root.geometry('500x300')
root.title("Youtube video downloader")

tkinter.Label(root, text="Youtube video download", font='arial 20 bold').pack()


#link input. input field for the user to insert the copied youtube link.
Link = tkinter.StringVar()

tkinter.Label(root, text='Paste your link', font='arial 15 bold').place(x = 160, y = 60)

link_enter = tkinter.Entry(root, width = 70, textvariable = Link).place(x = 32, y = 90)



#function to download video

def Downloader():

    url =YouTube(str(Link.get()))
    video = url.streams.first()
    video.download()
    tkinter.Label(root, text ='DOWNLOADED', font ='arial 15').place(x= 180, y = 210)


#button that'll click once you're ready to download the video
tkinter.Button(root, text ='DOWNLOAD', font ='arial 15 bold', bg ='blue', padx = 2, command = Downloader).place(x=180, y = 150)






root.mainloop()