Download YouTube Videos Using Python | Source Code


How to Download YouTube Videos ?

You can download YouTube videos using Python. You have a library called pytube which can be used for downloading the video.

This requires Python 3 to Work

Start by installing the library using pip.

pip install pytest

Once you the library installed, use the below script to download the video:

import pytube
from pytube.streams import Stream

def downloadVideo(link):
	'''
    utility to download YouTube video 
    '''
	youTube = pytube.YouTube(link)
	stream = youTube.streams.get_highest_resolution()
	stream.download()

# pass the youtube video link to download
downloadVideo('https://www.youtube.com/watch?v=1VdNKq6otHY')