Download YouTube Video Using Python

Download YouTube Video Using Python

This is just a two-line youtube video downloader python program but to explain it in a better way we have used the comments.

If you want the source code for the GUI application to download YouTube Video then click here.

So, first, let’s see the two-line code to download any youtube video.

from pytube import YouTube
YouTube("link").streams.first().download()

We have explained this program in every line to make it understand easily for you.

You can download the pytube module using"pip install pytube" but if this gives you the error then you should try "pip install pytube3" inside your terminal.

Now, let’s see the code and understand.

Code

# importing YouTube from pytube
from pytube import YouTube
# asking user to enter link
link = input("Enter the link ")
# showing user that the process has started
print("Downloding...")
# main code to download Video
YouTube(link).streams.first().download()
# showing user that the video has downloaded
print("Video downloaded successfully")

Output

Enter the link https://youtu.be/a-MWCVa0tlY 
Downloding...
Video downloaded successfully

Also read:

  • Bakery Management System in Python | Class 12 Project
    In this article, we are going to build one such application that can manage a bakery. Yes! The bakery products are everyone’s favorite, right? We are going to build a console-based Bakery Management System in Python that can manage our bakery which cooks delicious kinds of stuff! This article is your end of wander for…
  • Filter List in Python | 10 methods
    Filter List in Python is the process of selecting specific items from a list that meet certain criteria. This is a task that you will encounter every now and then if you are working with python. So here you will learn 10 different ways to filter List in Python. 1. Using for loop We start…
  • Top 25 Pattern Programs in C++
    In this article, I will show you the Top 25 Pattern Programs in C++ that you must learn which will help you to understand the usage of nested loops. We will learn to create different geometrical shapes like Squares, triangles, Rhombus, etc. We have provided the code as well as output for all the patterns…
  • Currency Converter in C++
    In this article, we will build a simple program for Currency Converter in C++. The user will be able to convert currencies like Dollar, Euro, Pound, and Rupee. This is a console application and very simple to understand as we only use a bunch of conditionals to write the entire program. Features Users can convert…
  • SQLite | CRUD Operations in Python
    CRUD stands for Create Read Update Delete. I will show you how to perform CRUD Operations in Python. You need basic Tkinter and SQLite knowledge before you read further. This app is straightforward, when you will open this app, a GUI with 4 green colored buttons will open to perform CRUD(create read update delete) operations….


Share:
Avatar of Harry

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at admin@copyassignment.com Thank you