how to download youtube videos using python script / pytube


how to download youtube videos using python script / pytube

Hello everyone in this article we will learn how to download youtube videos using python script / pytube so follow every step one by one

Let’s see:

Step 1 : Install pytube lib. in your compiler

Before start writing our program logic we need to install all required Liabrary like

  1. pytube
  2. import tkinter

Windows shows initial installation

Step 1 : Install pytube lib. in your compiler
Step 1 : Install pytube lib. in your compiler

Step 2 : Write complete source code for downloading youtube videos

After the successfully installation of required library we free for writing our logical code .

Step 2 : Write complete source code for downloading youtube videos
Step 2 : Write complete source code for downloading youtube videos

Step 3 : Run or compile source code

Run or compile source code
Run or compile source code

After the compilation source code one pop-up windows open here we need to paste youtube link which we want to download. after the enter the download button downloading start

Source code for download youtube videos using python script / pytube

Below are source code available

from future.moves import tkinter
from tkinter import *
from pytube import YouTube

sach = Tk()
sach.geometry('500x300')
sach.resizable(0,0)
sach.title("sach youtube downloader")

Label(sach,text = 'Youtube Video Downloader', font ='arial 20 bold').pack()

link = StringVar()

Label(sach, text = 'Paste Link Here:', font = 'arial 15 bold').place(x= 160 , y = 60)
link_enter = Entry(sach, width = 70,textvariable = link).place(x = 32, y = 90)


def Downloader():
    url =YouTube(str(link.get()))
    video = url.streams.first()
    video.download()
    Label(sach, text = 'DOWNLOADED', font = 'arial 15').place(x= 180 , y = 210)

Button(sach,text = 'DOWNLOAD', font = 'arial 15 bold' ,bg = 'pale violet red', padx = 2, command = Downloader).place(x=180 ,y = 150)

sach.mainloop()

so finally our project ready to download youtube video so enjoy it.

Summary :

In this article we saw how to download youtube videos using python script / pytube . about this article you have any query then free to ask me

I am Mr. Sachin pagar the founder of Pythonslearning, a Passionate Educational Blogger and Author, who love to share the informative content on educational resources.

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *