Python Video Processing: Download YouTube Videos Using pafy

In this tutorial, we will introduce how to download youtube videos using python pafy package.

Python Video Processing: Download YouTube Videos Using pafy

1.Install pafy

pip install pafy

2.Import library

import pafy

3.Prepare a youtube video url

url = 'https://www.youtube.com/watch?v=-t1_ffaFXao'

4.Start to download youtube video using pafy

video = pafy.new(url)
best = video.getbest()
filename = best.download(filepath='videos/' + title + '.' + best.extension)