3

I'm Downloading a Playlist which has some hidden Videos so python gives me DownloadError, I want to Download the Whole Playlist at once. Is there a fix for that. I'm trying to see if I can make it ignore those hidden videos

My Code:

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)

Error Given in Terminal:

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
Grant Birchmeier
  • 17,809
  • 11
  • 63
  • 98
Sara
  • 33
  • 1
  • 3
  • 1
    You can use the `--ignore-errors` or `--no-abort-on-error` flag. See: https://github.com/yt-dlp/yt-dlp/blob/a1ddaa899ca8693f31f34770f7263ace7e8c8841/README.md#general-options – Random Davis Apr 27 '22 at 18:14
  • where do i add it?? this code is run in VS code – Sara Apr 27 '22 at 18:28
  • Scroll up on that page; it says that in the command line, you can run `yt-dlp`, and pass that flag to the command, along with the playlist URL of course. If you want to do it from a Python script, which wouldn't be necessary if you just want to do this one time, then I'm not sure how you'd pass that flag, but there's got to be a way. – Random Davis Apr 27 '22 at 18:33
  • Actually, on that same Readme, it explains how to pass options to the `YoutubeDL` object. Here is an example of options being passed: https://github.com/yt-dlp/yt-dlp#extract-audio Except in your case you'd use the `ignoreerrors` option which is defined [here](https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L181). – Random Davis Apr 27 '22 at 18:36

1 Answers1

2

Based on my understanding of the documentation, I think this will do what you want - unfortunately I cannot test it at the moment, so let me know if it doesn't work:

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)
Random Davis
  • 6,662
  • 4
  • 14
  • 24