Search code examples
pythonyoutube-dl

Youtubedl CERTIFICATE_VERIFY_FAILED


I ran this code in Python:

from __future__ import unicode_literals
import youtube_dl


ydl_opts = {
    'format': 'bestaudio/best',
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '192',
    }],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['YOUTUBE URL'])

I was hoping it would convert the Youtube video to a URL file.

I got a really long error which basically repeated this:

[0;31mERROR:[0m Unable to download webpage: (caused by URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))

I have searched online but a unsure on how to solve this problem?


Solution

  • Add the no-check-certificate parameter to the command:

    youtube-dl --no-check-certificate
    

    This option was renamed to --no-check-certificates starting with version 2021.10.09 (inclusive).