Professional Documents
Culture Documents
Donate
You can quickly watch videos with a few mouse clicks, but
downloading videos is difficult. But in a recent upgrade,
YouTube now allows you to save videos in its download folder
for offline viewing. Still, you are unable to save them locally.
Prerequisites
Below are the basic requirements to proceed with this tutorial:
Forum
Donate
Understanding oftothe
Learn Python
code — freeProgramming language
3,000-hour curriculum
To install Pytube using pip, you will need to open your command
prompt CLI as an administrator and enter the following
command:
def Download(link):
youtubeObject = YouTube(link)
youtubeObject = youtubeObject.streams.get_highest_resolution()
try:
youtubeObject.download()
except:
print("An error has occurred")
print("Download is completed successfully")
The youtubeObject =
youtubeObject.streams.get_highest_resolution() command
will automatically download the highest resolution available.
The Link function will ask for the preferred YouTube video link
to download, then immediately after you hit the enter button,
the video downloading will commence.
The Output:
Forum
Donate
The video I downloaded was successful. You can see the video in
the same Python folder where the file you are working on is
located. But if you wish, you can then move the video to your
preferred storage location. In my case the video name is
"Ronaldo celebrates with Antony.mp4."
Conclusion
We have successfully built a YouTube video downloader script
of our own in Python. This helps you avoid the stress of looking
for an external website or application to get your preferred
video to your local storage.
Forum
Donate
It also saves you from having to expose your data on a third-
Learn to code — free 3,000-hour curriculum
party website or phishing link – all in the name of getting a video
from YouTube to your local storage.
David Fagbuyiro
Software engineer, Technical writer, and Web 3.0 enthusiasts
If you read this far, tweet to the author to show them you care.
Tweet a thanks
Our mission: to help people learn to code for free. We accomplish this by
creating thousands of videos, articles, and interactive coding lessons - all
freely available to the public. We also have thousands of freeCodeCamp Forum
Donate
study groups around the world.
Donations to freeCodeCamp go to
Learn toward
codeour education
— free initiatives,
3,000-hour and help
curriculum
pay for servers, services, and staff.
Trending Guides
Our Nonprofit
About Alumni Network Open Source Shop Support Sponsors Academic Honesty