在失败的碎片上中止作业 yt-dlp

Abort job on failed fragements yt-dlp

我在 python 3.9.1 中编写了一个使用 yt-dlp 的下载器,使用的格式是:

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]])

然而有些下载会跳过片段(由于超时或其他原因),给我留下一些被剪短的东西。

知道我需要在 ydl_opts 中添加什么吗?我认为 'abort-on-unavailable-fragment': True 就足够了,但下载继续并使用 ffmpeg 处理文件。

知道我如何解决这个问题吗?如果它开始无法下载片段,只需中止作业并删除它创建的任何文件?也许我调用的选项不正确?

选项名为 skip_unavailable_fragments。见 docstring of FragmentFD

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

yt-dlp 中没有自动删除临时文件的功能。你将不得不捕获错误并自己做