-
-
Save WilCF/d409a775bb4db9083275b8e381958998 to your computer and use it in GitHub Desktop.
Download YouTube Videos in Mp4 Format using Python Pytube module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you @yogeshsinghgit for the original code