Course Content
What is Python?
Introduction of Python and Its setup
0/2
Control Statement
Control statements are used to control the flow of execution depending upon the specified condition/logic.
0/4
File Handling
File handling is an important component of any application. Python has multiple functions for creating, reading, updating, and deleting files.
0/2
Examples
Following are the examples of python scripts to try hands-on, you are ready to start your python journey.
0/7
Python
About Lesson

Youtube Downloader using Python

  1. Step 1: Download library
    pip install pytube3

    This will download the library

  2. Step 2: Import library
    from pytube import YouTube

    This will import the library

  3. Step 3: Accept input from the user
    link     = input("Enter the link: ")
    yt      = YouTube(link)
  4. Step 4: Display video information
    # Title of the video
    print(f"Title: {yt.title}")
    
    # Number of views
    print(f"Views: {yt.views}")
    
    # Length of the video
    print(f"Duration: {yt.length}")
    
    # Description
    print(f"Description: {yt.description}")

    This will display more information about the video.

  5. Step 5: Check for available streams
    print(yt.streams)
  6. Step 6: Check for Highest Quality
    print(yt.streams.filter(progressive=True))
    ys = yt.streams.get_highest_resolution()
  7. Step 7: Download video
    ys.download()
    print("Download completed !!")

Example Source Code

from pytube import YouTube

link    = input("Enter the link: ")
yt      = YouTube(link)

# Title of the video
print(f"Title: {yt.title}")

# Number of views
print(f"Views: {yt.views}")

# Length of the video
print(f"Duration: {yt.length}")

# Description
print(f"Description: {yt.description}")

# Available Streams
print(yt.streams)

print(yt.streams.filter(progressive=True))
ys = yt.streams.get_highest_resolution()

ys.download()
print("Download completed !!")