如何使 Python 模块 yt-dlp 在下载播放列表时忽略私人视频

How to Make Python Module yt-dlp ignore Private Videos When Downloading A Playlist

我正在下载一个包含一些隐藏视频的播放列表,所以 python 给我 DownloadError,我想一次下载整个播放列表。有没有解决办法。 我正在尝试看看是否可以让它忽略那些隐藏的视频

我的代码:

from yt_dlp import YoutubeDL

url = 'https://www.youtube.com/playlist?list=PLzMXToX8KzqhKrURIhVTJMb0v-HeDM3gs'
ydl_opts = {'format': 'mp4'}
with YoutubeDL(ydl_opts) as ydl:
    ydl.download(url)

终端出现错误:

Enter your URL: https://youtube.com/playlist?list=PLzMXToX8KzqhKrURIhVTJMb0v-HeDM3gs
[youtube:tab] PLzMXToX8KzqhKrURIhVTJMb0v-HeDM3gs: Downloading webpage
WARNING: [youtube:tab] YouTube said: INFO - 8 unavailable videos are hidden
[youtube:tab] PLzMXToX8KzqhKrURIhVTJMb0v-HeDM3gs: Downloading API JSON with unavailable videos
WARNING: [youtube:tab] YouTube said: INFO - Unavailable videos will be hidden during playback
[download] Downloading playlist: English Grammar
[youtube:tab] playlist English Grammar: Downloading 52 videos
[download] Downloading video 1 of 52
[youtube] JGXK_99nc5s: Downloading webpage
[youtube] JGXK_99nc5s: Downloading android player API JSON
ERROR: [youtube] JGXK_99nc5s: Private video. Sign in if you've been granted access to this video

根据我对文档的理解,我认为这会做你想做的事 - 不幸的是我现在无法测试它,所以如果没有,请告诉我工作:

import yt_dlp

ydl_opts = {
    'ignoreerrors': True
}

url = 'https://www.youtube.com/playlist?list=PLzMXToX8KzqhKrURIhVTJMb0v-HeDM3gs'
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
    error_code = ydl.download(url)