I'm making a Python script to download videos from multiple sites using youtube-dl:
from __future__ import unicode_literals
import youtube_dl
downloadLinks = []
downloadLink = input('Link to download: ')
downloadLinks.append(downloadLink)
youtube_dl_options = {
"outtmpl": "%(title)s-%(id)s.%(ext)s",
"restrictfilenames": True,
"nooverwrites": True,
"writedescription": True,
"writeinfojson": True,
"writeannotations": True,
"writethumbnail": True,
"writesubtitles": True,
"writeautomaticsub": True
}
with youtube_dl.YoutubeDL(youtube_dl_options) as ydl:
ydl.download(downloadLinks)
Well the problem is I want to download always the 1080p version of the video, but in some cases it only download the 720p ("best") version, how I can based on code tell to youtube-dl to download the 1080p only.
in the options we need to put the format like this:
youtube_dl_options = {
"format": "mp4[height=1080]", # This will select the specific resolution typed here
"outtmpl": "%(title)s-%(id)s.%(ext)s",
"restrictfilenames": True,
"nooverwrites": True,
"writedescription": True,
"writeinfojson": True,
"writeannotations": True,
"writethumbnail": True,
"writesubtitles": True,
"writeautomaticsub": True
}