First Make Sure That you Have Install Python 3 on your System.
Check Python Version.
python --version
Step 1 : Install pytube3.
pip install pytube3
Step 2 : Open any text editor and import the YouTube from pytube
from pytube import YouTube
Step 3 : Create one variable and pass the link of video in YouTube class.
yt = YouTube("https://www.youtube.com/watch?v=wTmFilUkClY")
We can also retrieve data of video like title, length, views, rating etc.
print(yt.rating)
Step 4 : Write the download function.
pytube offers a very easy way to see all the available streams for the link user has provided.
we can see the streams by printing "yt.streams"
print(yt.streams)
To get the highest resolution progressive stream available, we can just write
ys = yt.streams.get_highest_resolution()
Now let's download over video.
ys.download().
This will download our preferred stream and save it in the current working directory.
We can also specify the location in our system where we want to download the YouTube video. We can do so by specifying the absolute path in between the braces of download.
Use it for testing and educational purposes only. Do not misuse this knowledge.
Thank You !!!
0 Comments