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 !!")