How To Make a YouTube Video Downloader in Python | PyTube

The goal of this tutorial on How To Make a YouTube Video Downloader in Python is to download any kind of video in a quick and easy way from YouTube to your gadget.

This YouTube Video Downloader In Python is developed using Python TKinter Graphical User Interface (GUI), this YouTube Downloader Python is an application to download recording videos from YouTube.

Project Name:YouTube Downloader in Python
Language/s Used:Python (GUI) Based
Python version (Recommended):2.x or 3.x
Database:None
Type:Python App
Developer:IT SOURCECODE
Updates:0
How To Make a YouTube Video Downloader in Python

This allows clients/users to download recording videos they need on their gadgets and watch them when they have no internet connection.

For this Python project, the user has to copy the YouTube video URL that they want to download and simply paste that URL in the ‘paste link here’ section and click on the download button, it will start downloading the video.

When video downloading finishes, it shows a message ‘downloaded’ popup on the window below the download button.

This article also includes a downloadable Python Source Code for free, just find the downloadable source code below and click to start downloading.

To start Creating a YouTube Video Downloader, make sure that you have Pycharm IDE installed on your computer.

By the way, if you are new to Python programming and don’t know what Python IDE to use, I have here a list of Best Python IDE for Windows, Linux, and Mac OS that will suit you. I also have here How to Download and Install Latest Version of Python on Windows.

Steps on How To Create YouTube Video Downloader Using Python With Source Code

Time needed: 5 minutes

How To Make a YouTube Video Downloader Using Python With Source Code

  • Import Libraries.

    First, start the project by importing the required modules.

    *pip install tkinter
    *pip install pytube

  • Create Display Window.

    Second, create a GUI interface using Tkinter.
    How To Create Youtube Video Downloader Using Python display window

  • Create Field to Enter Link.

    Third, create a field for the link that gets in YouTube. The next thing we would do would be to ask the user for the link to the YouTube video we need to download. After that, the user will give us the link to the video he wants to download.
    field to enter link

  • Create a Function Button to Start Downloading

    Fourth, create a functioning button to run the code and start downloading functionality.
    function button

Code Explanations

1. Importing Libraries

Code:

#tkinter import

import tkinter
from pytube import YouTube

Explanation:

The code given above is the project libraries that are required to import in your command line.

2. Design of the Project

Code:

#label root text

root = tkinter.Tk()

#entry root width

root.geometry('500x300')
root.resizable(0,0)
root.title("IT SOURCECODE Youtube Video Downloader")


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

Explanation:

The code given above is the design of the project.

Code:

link = tkinter.StringVar()

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

Explanation:

The code given above is the input field of the URL to be downloaded.

4. Function To Download The Video

Code:

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


tkinter.Button(root, text ='DOWNLOAD', font ='arial 15 bold', bg ='blue', padx = 2, command = Downloader).place(x=180, y = 150)



root.mainloop()

Explanation:

The code given above is the function to start downloading the video.

Complete Source Code

import tkinter
from pytube import YouTube

root = tkinter.Tk()
root.geometry('500x300')
root.resizable(0,0)
root.title("IT SOURCECODE Youtube Video Downloader")


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




##enter link
link = tkinter.StringVar()

#youtube URL

tkinter.Label(root, text ='Paste Link Here:', 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)


tkinter.Button(root, text ='DOWNLOAD', font ='arial 15 bold', bg ='blue', padx = 2, command = Downloader).place(x=180, y = 150)



root.mainloop()

Output

Downloadable Source Code Below

I have here the list of Best Python Project with Source code free to download for free, I hope this can help you a lot.

Summary

With this project in Python, we have successfully developed How To Make YouTube Video Downloader in Python. We used the popular Tkinter library that used for rendering graphics. We use the Pytube library to download videos from YouTube.

Related Article Below

Inquiries

If you have any questions or suggestions about How To Make a YouTube Video Downloader in Python, please feel free to leave a comment below.

3 thoughts on “How To Make a YouTube Video Downloader in Python | PyTube”

Leave a Comment