In this post we will make a application that will download our YouTube Videos from Python
This application will download any YouTube Videos just give the link of YouTube Video and select the resolution of the video. It will download and save where you save you your python code file
Here is the code :-
#This Will Download Only 1080p Resolution Video
import pytube
print("Give URL:")
url = input()
pytube.YouTube(url).streams.get_highest_resolution().download('../Video')
#This Will Download Only Video From 144p To 720p But When You Select In 1080p There Will No Audio
# ./pytube_demo.py
from pytube import YouTube
def get_stream_for_res(streams, res):
stream = list(filter(lambda x: x.resolution == res, streams))
return stream
video_url = input("Enter YouTube Video URL: ").strip()
youtube_obj = YouTube(video_url)
video_res = input(f"Enter YouTube Video Resolution for {youtube_obj.title}: ").strip()
req_stream_obj = get_stream_for_res(youtube_obj.streams, video_res)[0]
req_stream_obj.download()
print(f"YouTube Video {youtube_obj.title} Downloaded With Resolution {video_res}")