Last active
June 2, 2024 13:30
-
-
Save yogeshsinghgit/14241e51d3d4d67571ef999647fb7c67 to your computer and use it in GitHub Desktop.
Download YouTube Videos in Mp4 Format using Python Pytube module
This file contains hidden or 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
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