Downlaod Youtube Video in Any Format Using Python Pytube Library

1736876373.png

Written by Aayush Saini · 3 minute read · Jun 23, 2020 . Python, 91

Hi Everyone, In this Post, We learn How we can Download Youtube Video in Any Format Using Python Pytube Library. We need to install the Python Pytube Library for Downloading Any Youtube Video.

We Complete this program with a few Steps,

  1. Import Pytube Library
  2. Get Youtube URL from User Input
  3. Print All Possible Format
  4. Input Path Where Save the Video

Complete Program

#import Library
from pytube import YouTube
print("Enter Youtube video url : ")
url = input()
print('Please Wait till a minute....')
yt = YouTube(url)
videos = yt.streams.all()
s = 1
for v in videos:
    print(str(s)+ ". "+str(v))
    s += 1
    
print("Enter the number of the video: ")
n = int(input())
vid = videos[n-1]
print("Enter the destination Path Where You want to save this File : ")
destination = input()
print('Please Wait till a minute....')
vid.download(destination)
print("\nYour File has been successfully downloaded")
 
1. [Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2" progressive="True" type="video"]
2. [Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028" progressive="False" type="video"]
3. [Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9" progressive="False" type="video"]
4. [Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f" progressive="False" type="video"]
5. [Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9" progressive="False" type="video"]
6. [Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e" progressive="False" type="video"]
7. [Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9" progressive="False" type="video"]
8. [Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e" progressive="False" type="video"]
9. [Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9" progressive="False" type="video"]
10. [Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015" progressive="False" type="video"]
11. [Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9" progressive="False" type="video"]
12. [Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c" progressive="False" type="video"]
13. [Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9" progressive="False" type="video"]
14. [Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2" progressive="False" type="audio"]
15. [Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus" progressive="False" type="audio"]
16. [Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus" progressive="False" type="audio"]
17. [Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus" progressive="False" type="audio"]

  • First Enter Url Of Youtube Video
  • Select the Number Which format you Want to Download
  • Enter Path of Your Computer Where you want to Save this Video then wait till a Minte Your Video is Downloaded 

Thanks for Reading Share this Post 

Share   Share