In this video, we will examine how to download video media from YouTube.
Some content, such as video on YouTube, can be complex to download.
However,
there are many libraries available to us such as
Pafy that we can use to save time.
Pafy is open source and is an extremely useful tool for
extracting video media from YouTube.
It's very important to point out that,
like any form of web scraping, before you start downloading any
content from YouTube or any other website,
you must ensure that you have the content owner's full permission to do so.
Always check the terms and conditions. In this example, we'll use
Pafy to download a Pluralsight promotional video.
And, yes, I've checked, and we have permission.
It's quite simple, and it only requires a few lines of code.
We start out by creating a variable to hold the URL of the video we require
and then create a new instance of Pafy and pass in the video URL as a
parameter. Pafy has a lot of very cool options.
Among these is the ability for it to choose the best
resolution video available for download.
To download the video,
we simply call the download function telling Pafy where we want the data stored.
In addition to downloading the video itself,
Pafy can also give us other useful information about the media from YouTube,
including view count, ratings, and available thumbnail images.