将参数传递给 youtube-dl

问题描述:

我想通过 --ignore-errors(link) 参数到我的 youtube-dl 对象,我似乎做对了.代码如下:

I want to pass the --ignore-errors(link) parameter to my youtube-dl object and i can't seem to be doing it right. Here's the code:

options = {
'format': 'bestaudio/best',
'ignore-errors': True,
'postprocessors': [{
    'key': 'FFmpegExtractAudio',
    'preferredcodec': 'mp3',
    'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(options) as youtube_object:
    meta = youtube_object.extract_info(link, download = False)

我正在尝试下载的播放列表中的一个视频给了我一个错误,我想忽略该视频(正是 cmd --ignore-error 的作用)但是我如何将其集成到脚本中?

One of the videos from the playlist i'm trying to download gives me an error and i should like to ignore that video(exactly what the cmd --ignore-error does) but how can i integrate it in a script?

您需要的选项是 忽略错误

Option you need is ignoreerrors

查看从命令行参数到代码内"的映射的最简单方法是查看 cli 规范.它基于内置 optparse 库,您正在寻找 dest 参数.

Easiest way to see mapping from command-line params to "in-code" is to look into cli spec. Its based on build-in optparse lib, and you're looking for dest argument.