Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--no-check-certificate option in pafy ? #148

Open
bharadwajpro opened this issue Jul 8, 2016 · 7 comments
Open

--no-check-certificate option in pafy ? #148

bharadwajpro opened this issue Jul 8, 2016 · 7 comments

Comments

@bharadwajpro
Copy link

--no-check-certificate option in youtube-dl suppresses HTTPS certificate verification. Is there any similar option for not checking SSL certificate in pafy ?

@bharadwajpro bharadwajpro changed the title --no-check certificate option in pafy ? --no-check-certificate option in pafy ? Jul 8, 2016
@ids1024
Copy link
Contributor

ids1024 commented Jul 11, 2016

If the youtube-dl backend is being used, youtube-dl options can be passed to pafy by passing a ydl_opts argument to pafy.new().

@bharadwajpro
Copy link
Author

How to pass --no-check-certificate option to ydl_opts which can be passed to pafy.new() ? Can you please provide the example code. I looked everywhere in the internet and your documentation. It is unclear. I tried the below code but it is displaying error as ERROR: Unable to download webpage: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED]. The code is
import pafy
url = "https://www.youtube.com/watch?v=iyLiep0mM0A"
ydl_opts = {"--no-check-certificate": True}
myvid = pafy.new(url, ydl_opts)

I tried using youtube-dl and it works fine. I think the problem is I am passing --no-check-certificate in the wrong way to ydl_opts. I know there is some SSL_CERTIFICATE problem that needs to be fixed. But first I want to know how to skip HTTPS verification in pafy ?

@ritiek
Copy link
Member

ritiek commented Jun 11, 2017

I am having the same issue. I tried pafy.new(url, ydl_opts={'nocheckcertificate': True}) looking deeper here but it does not seem to work either.

@ids1024
Copy link
Contributor

ids1024 commented Jun 12, 2017

Perhaps the issue is due to the API calls pafy itself makes? Exactly what error do you get?

@ritiek
Copy link
Member

ritiek commented Jun 12, 2017

@ids1024 I upgraded my python from v2.7.11 to v2.7.13 and now everything seems to work correctly without even using --no-check-certificate option. I don't remember the exact error but it was very similar to the one in this issue on youtube-dl.

ERROR: Unable to download webpage: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)> (caused by URLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)'),))

Thanks anyway! 😄

@KirkSuD
Copy link

KirkSuD commented Jul 17, 2017

@ids1024 I found that ydl_opts aren't passed into youtube_dl.
In pafy.py, function new, return Pafy(url, basic, gdata, size, callback, ydl_opts).
In backend_youtube_dl.py, class YtdlPafy, function __init__, ydl_opts = kwargs.get("ydl_opts").
Looks like it's passing arguments, not keyword arguments, so kwargs.get won't get anything!!!
New to github, if I said anything wrong, please tell me immediately. 😄

@pixelein
Copy link

pixelein commented Feb 16, 2019

Hello everyone,
I know it's too late to answer, but my answer may help someone. So...
There was an issue, when I run mpsyt and try to search some thing the annoying error message shown:
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)>
I figured out this message comes from openssl, then I just added these lines to pafy/backend_shared.py and pafy/backend_internal.py after lines 6 and 9 accordingly:

import ssl

ssl._create_default_https_context = ssl._create_unverified_context

and a line self._ydl_opts['nocheckcertificate'] = True to pafy/backend_youtube_dl.py

if ydl_opts:
    self._ydl_opts.update(ydl_opts)
...
# after these lines like that (line 28)
self._ydl_opts['nocheckcertificate'] = True

then mpsyt works fine.
If you want youtube_dl work without checking certificate by default then you can change nocheckcertificate default parameter to True in line 354 of file youtube_dl/YoutubeDL.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants