Beginner Python Project (4) - YouTube Video Downloader
Tags: python, programming, productivity, codenewbie
Published: 2021-03-26 08:15:02

Am pretty sure we have all wanted at some point to download videos from YouTube, but we end up failing because we can't, or we even end up installing third party extensions which may be harmful to our machines. 
Hey, guess what, that's about to be over, I am going to show you how you can fix all that using simple python program.
Let's get started!! 
You can Also Watch the Video Here:
[![How to make a YouTube Video Downloader Using Python](https://res.cloudinary.com/marcomontalbano/image/upload/v1616746678/video_to_markdown/images/youtube--kE755KphAcs-c05b58ac6eb4c4700831b2b3070cd403.jpg)](https://www.youtube.com/watch?v=kE755KphAcs "How to make a YouTube Video Downloader Using Python")
Our goal is to create a YouTube video downloader using python, Tkinter and Pytube. 
first make sure you have an IDE, preferably Pycharm installed in your computer.
### Steps 
- First you will start by installing pytube, open the terminal and run the following command:
``` python
pip install pytube
```
- next step we will import the library together with tkinter
```python
import tkinter as tk
from pytube import YouTube
```
- After importing we will have to create the display window using tkinter:
```python
#Dispaly Window
dock = tk.Tk()
dock.geometry('500x300')
dock.resizable(0,0)
dock.title("TechTips By Lary Youtube Video Downloader")
tk.Label(dock, text ="Youtube Video Downloader", font ="arial 20 bold").pack()
```  
Here we have specified the size, and also given it a title to display at the top. We have also added some inline styling to our code.
- We will create the field that's goint to allow us to enter the video link to be downloaded:
```python
#Enter the URL
link = tk.StringVar()

tk.Label(dock, text ="Paste Link Here:", font ="arial 15 bold").place(x=160, y=60)
link_error = tk.Entry(dock, width =70, textvariable = link).place(x =32, y=90)
```
- The next step is to create the main function that's going to enable us download the video and then finally adding a button.
```python
#Function to download the video
def Downloader():
    url =YouTube(str(link.get()))
    video =url.streams.first()
    video.download()
    tk.Label(dock, text ="Successfully Downloaded", font ="arial 15").place(x =180, y =200)

#Download Button
tk.Button(dock, text ="DOWNLOAD", font ="Verdana 15 bold", bg ="orange", padx =2, command =Downloader).place(x=180, y=150)

dock.mainloop()
```
That's pretty much it now run the program by right clicking then select run. and a window should pop up like below:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/01nzdy4awpcbr2mdzrgw.PNG)
Like my work: 
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/V7R03ZL69)
Also check out my other Python Beginner Projects: 
- [Instagram SpamBot](https://dev.to/larymak/make-an-instagram-spam-bot-3b0h)
- [WhatsApp SpamBot](https://dev.to/larymak/beginner-python-projects-part-1-5h1d)  


Connect With me at [Twitter](https://twitter.com/larymak1) | [Insta](https://www.instagram.com/nextgencoders/) | [YouTube](https://www.youtube.com/channel/UCrT1ARRZfLOuf6nc_97eXEg) | [LinkedIn](https://www.linkedin.com/in/hillary-nyakundi-3a64b11ab/) | [GitHub](https://github.com/larymak)

Do share your valuable opinion, I appreciate your honest feedback!    

Enjoy Coding ❤