Skip to content

Instantly share code, notes, and snippets.

@yogeshsinghgit
Last active April 27, 2024 18:19
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save yogeshsinghgit/14241e51d3d4d67571ef999647fb7c67 to your computer and use it in GitHub Desktop.
Save yogeshsinghgit/14241e51d3d4d67571ef999647fb7c67 to your computer and use it in GitHub Desktop.
Download YouTube Videos in Mp4 Format using Python Pytube module
from pytube import YouTube
def download_Video(yt):
# filter mp4 streams from object
my_streams = yt.streams.filter(file_extension='mp4',only_video=True)
for streams in my_streams:
# print itag, resolution and codec format of Mp4 streams
print(f"Video itag : {streams.itag} Resolution : {streams.resolution} VCodec : {streams.codecs[0]}")
# enter the itag value of resolution on which you want to download the video
input_itag = input("Enter itag Value : ")
# get video using itag vale
video = yt.streams.get_by_itag(input_itag)
# finally download the YouTube Video...
video.download()
print("Video is Downloading as",yt.title+".mp4")
link = "Enter Your Link Here"
# Create YouTube Object.
yt = YouTube(link)
# call The function..
download_video(yt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment