Reputation: 69
from __future__ import unicode_literals
import youtube_dl
ydl_opts = {}
url = input("Enter your URL:")
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
if
ydl.download([url])
print("Downloaded!")
By default, it is downloading 360p videos. However, I want to download what is best resolution for that particular video. Could anyone help me? Thank you.
Upvotes: 0
Views: 1697
Reputation: 660
Use the format option
If you want the best video format use bestvideo.
Example:
url = input("Enter your URL:")
ydl = youtube_dl.YoutubeDL({
'outtmpl': '/tmp/testvideo.mp4',
'format':' bestvideo+bestaudio'
})
ydl.download([url])
Edit: If you want to have the video and audio in 1 File, do:
'format':' bestvideo[ext=mp4]+bestaudio[ext=mp4]/mp4'
Instead of
'format':' bestvideo+bestaudio'
Upvotes: 2