Search code examples
pythonyoutube-dl

Abort job on failed fragements yt-dlp


I've written a downloader in python 3.9.1 that utilizes yt-dlp, using this format:

outTmpl = "{}"
rows = c.fetchall()
ydl_opts = dict()
for row in rows:
    ydl_opts = {
    'verbose': True,
    'outtmpl': outTmpl.format(row[1]),
    'abort-on-unavailable-fragment': True,
    }
    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        ydl.download([row[0]])

However some downloads skip fragments (due to timeouts or whatever), leaving me with something that is cut short.

Any idea what i need to put in the ydl_opts? I thought 'abort-on-unavailable-fragment': True would suffice, but the download carries on and processes the file with ffmpeg.

Any idea how i fix this please and if it starts failing to download segments, just abort the job and remove any files its created? Maybe the option i'm calling is incorrect?


Solution

  • The option is named skip_unavailable_fragments. See the docstring of FragmentFD

    if it starts failing to download segments, just abort the job and remove any files its created?

    There is no functionality in yt-dlp to automatically remove the temporary files. You will have to catch the error and do it yourself