In python, is it possible to stop a youtube-dl download if it becomes larger than a specified size?
I am using youtube_dl imported into python:
import youtube_dl
ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(urls)
Is it possible to stop the .download() function early if it gets too big?
Like @larsks said in the comments,
adding max_filesize
to the ydl_opts
works
import youtube_dl
ydl_opts = {
'max_filesize': <number_of_bytes>
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(urls)