Skip to content

Instantly share code, notes, and snippets.

@WilCF
Forked from yogeshsinghgit/download_as_video.py
Last active March 8, 2023 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WilCF/d409a775bb4db9083275b8e381958998 to your computer and use it in GitHub Desktop.
Save WilCF/d409a775bb4db9083275b8e381958998 to your computer and use it in GitHub Desktop.
Download YouTube Videos in Mp4 Format using Python Pytube module
# gets highest resolution and prompts user for yt link, otherwise identical to yogeshsinghgit's https://gist.github.com/yogeshsinghgit/14241e51d3d4d67571ef999647fb7c67
from pytube import YouTube
def download_video(yt):
# get highest resolution mp4 stream
stream = yt.streams.get_highest_resolution()
# print resolution and codec format of highest resolution mp4 stream
print(f"Video Resolution : {stream.resolution} VCodec : {stream.codecs[0]}")
# download the YouTube video
stream.download()
print("Video is Downloading as", yt.title + ".mp4")
# prompt user for the YouTube link
link = input("Enter Your Link Here: ")
# create YouTube object
yt = YouTube(link)
# call the function to download the video
download_video(yt)
@WilCF
Copy link
Author

WilCF commented Mar 8, 2023

Thank you @yogeshsinghgit for the original code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment