pip install youtube-dl
python
import youtube_dl
python
def download_hd_video(video_url):
ydl_opts = {
'format': 'bestvideo[height<=1080]+bestaudio/best[height<=1080]',
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([video_url])
python
if __name__ == "__main__":
video_url = "https://www.youtube.com/watch?v=video_id"
download_hd_video(video_url)