Original topic:

This tutorial is "How to Download Youtube videos in Python.

(Topic created on: 05-23-2020 09:57 PM)
814 Views
SamNoteUser
Expert Level 1
Options
Others

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')
0 Likes
0 Comments