George Karanikolas
Posted on May 21, 2020
Hello everyone!
This tutorial is "How to Download Youtube videos in Python.
_________________________________________________
Download Pytube Library
pip install pytube # python2
pip3 install pytube # python3
pip install pytube3 # if not work with pytube.
First of all, we need to import Pytube library :
import pytube
After that, You need copy the URL of the Youtube video :
url = 'https://www.youtube.com/watch?v=4SFhwxzfXNc'
Load url in function Youtube :
youtube = pytube.YouTube(url)
Set Streams Resolution :
video = youtube.streams.first()
# or
video = youtube.streams.get_highest_resolution()
Download Video :
video.download() # In Same Folder
# or
video.download('/Downloads') # In Other Folder
Get Information of Video :
video.title # Title
video.video_id # Id
video.age_restricted # Age
Streams Format :
video.streams.all()
stream = video.streams.all()
for i in stream:
print(i)
Example 1 :
import pytube
url = 'https://www.youtube.com/watch?v=4SFhwxzfXNc'
youtube = pytube.YouTube(url)
video = youtube.streams.first()
video.download('../Video')
Example 2 :
import pytube
print("Give URL:")
url = input()
pytube.YouTube(url).streams.get_highest_resolution().download('../Video')
I hope you liked it!
Library Creator : https://github.com/nficano/pytube
💖 💪 🙅 🚩
George Karanikolas
Posted on May 21, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.