anxdpanic / plugin.video.youtube

Watch your favorite YouTube content on Kodi
https://ytaddon.panicked.xyz/forum
696 stars 113 forks source link

SSLError 136 NO_CERTIFICATE_OR_CRL_FOUND #837

Closed bolet closed 4 months ago

bolet commented 4 months ago

Context

Please provide any relevant information about your setup


Expected Behavior

Play a YT video


Current Behavior

Login Error


Steps to Reproduce

The YT videos used to play fine, then suddenly there was this issue and I found those errors in the log. I can't remember having done anything special which could trigger the bug.

Please provide detailed steps for reproducing the issue.

  1. send a YT URL to kodi

Log

2024-07-08 23:13:25.657 T:16932    info <general>: [plugin.video.youtube] Running: YouTube (7.0.9+beta.2.unofficial.1) on Omega (Kodi-21.0) with Python 3.11.9
                                                   Path: /play/
                                                   Params: {'video_id': 'QVVe2rCHtN0', 'incognito': False}
2024-07-08 23:13:26.587 T:16932   error <general>: [plugin.video.youtube] Player request failed
                                                   exc: |HTTPSConnectionPool(host='www.youtube.com', port=443): Max retries exceeded with url: /youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8&prettyPrint=false (Caused by SSLError(SSLError(136, '[X509: NO_CERTIFICATE_OR_CRL_FOUND] no certificate or crl found (_ssl.c:4166)')))|
                                                   video_id: QVVe2rCHtN0, client: media_connect_frontend, auth: False
                                                   Stack trace (most recent call last):
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/plugin.py", line 16, in <module>
                                                       plugin_runner.run()
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/kodion/plugin_runner.py", line 63, in run
                                                       plugin.run(provider, context, focused=(current_uri == new_uri))
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/kodion/plugin/xbmc/xbmc_plugin.py", line 157, in run
                                                       result, options = provider.navigate(context)
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/kodion/abstract_provider.py", line 161, in navigate
                                                       result = handler['method'](context, re_match)
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/kodion/abstract_provider.py", line 376, in wrapper
                                                       return func(*args, **kwargs)
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/provider.py", line 718, in on_play
                                                       video = yt_play.play_video(self, context)
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/helper/yt_play.py", line 65, in play_video
                                                       video_streams = client.get_video_streams(context, video_id)
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/client/youtube.py", line 202, in get_video_streams
                                                       video_streams = video_info.load_stream_infos(video_id)
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/helper/video_info.py", line 837, in load_stream_infos
                                                       return self._get_video_info()
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/helper/video_info.py", line 1334, in _get_video_info
                                                       result = self.request(
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/kodion/network/requests.py", line 114, in request
                                                       stack_trace = format_stack()

2024-07-08 23:13:26.632 T:16932   error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'AttributeError'>
                                                   Error Contents: 'NoneType' object has no attribute 'get'
                                                   Traceback (most recent call last):
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/plugin.py", line 16, in <module>
                                                       plugin_runner.run()
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/kodion/plugin_runner.py", line 63, in run
                                                       plugin.run(provider, context, focused=(current_uri == new_uri))
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/kodion/plugin/xbmc/xbmc_plugin.py", line 157, in run
                                                       result, options = provider.navigate(context)
                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/kodion/abstract_provider.py", line 161, in navigate
                                                       result = handler['method'](context, re_match)
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/kodion/abstract_provider.py", line 376, in wrapper
                                                       return func(*args, **kwargs)
                                                              ^^^^^^^^^^^^^^^^^^^^^
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/provider.py", line 718, in on_play
                                                       video = yt_play.play_video(self, context)
                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/helper/yt_play.py", line 65, in play_video
                                                       video_streams = client.get_video_streams(context, video_id)
                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/client/youtube.py", line 202, in get_video_streams
                                                       video_streams = video_info.load_stream_infos(video_id)
                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/helper/video_info.py", line 837, in load_stream_infos
                                                       return self._get_video_info()
                                                              ^^^^^^^^^^^^^^^^^^^^^^
                                                     File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/helper/video_info.py", line 1348, in _get_video_info
                                                       video_details = result.get('videoDetails', {})
                                                                       ^^^^^^^^^^
                                                   AttributeError: 'NoneType' object has no attribute 'get'
                                                   -->End of Python script error report<--

Additional Information

The error was originally happening on addon version 7.0.5. I updated to latest beta, error still happens. I deleted addon with its data, and re-install. Error still happens in the logfile as soon as the code tries to fetch a https url.

The issue looks specific to YT, other addons still work fine.


MoojMidge commented 4 months ago

The issue looks specific to YT, other addons still work fine.

This has nothing to do with this plugin. There is something wrong with your system certificate store. Or maybe the certifi module.

You will need to check why your system certificate store does not contain the information that is required to verify/make a secure connection to the YouTube servers.

As a workaround you can disable https verification in the plugin advanced settings, but this is not a recommended course of action.

MoojMidge commented 4 months ago

Or maybe the certifi module.

There is a regression in the current 2.32.x releases of the requests module itself, that causes it to not load the default certificates from the certifi module when the default adapter is not used.

This will generate the type of errors you are seeing, but this version of requests isn't available in the kodi repositories...

A debug log is required when opening bug reports. If you had provided this, it would have been immediately obvious if this was the cause of the problem and also identified if you were loading a version of requests from your system Python installation rather than the one provided by Kodi.

Either way you should be able to revert whatever changes you did to upgrade requests until they release a fixed version.

bolet commented 4 months ago

I thought the portion of log I sent was enough for this issue. Should I send more? The startup portion? I also raised the issue on LibreElec forum. Maybe it could be worth having a look? Meanwhile I also tried a wget on the 1st URL, and though it fails, the error code shows we passed the https cert phase:

# wget -O- "https://www.youtube.com/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8&prettyPrint=false"
Connecting to www.youtube.com (216.58.214.174:443)
wget: server returned error: HTTP/1.1 405 Method Not Allowed

Any new thoughts?

MoojMidge commented 4 months ago

Info about creating a debug log is included when creating a bug report, but as I said before your problem doesn't have anything to do with this plugin specifically, I'm just trying to provide you with some info that you can use to resolve the problem yourself.

A debug log will be able to confirm whether what I'm guessing has happened (using an old version of LE12, with an old alpha version of Kodi v21 that has a bug with loading system python modules in preference to Kodi python modules, along with a new version of the requests module that has a regression associated with loading default certificates), has actually happened, but it's not something I have the time to look into for you.

Any new thoughts?

No, just what I have already advised - downgrade requests pip install --force-reinstall "requests<2.32"

Or upgrade LE.

Edit: I don't follow LE releases, but what I'm guessing has happened doesn't actually seem likely. You can try downgrading requests anyway, but it may still be an issue with the certifi module. Just too much missing information, and I'm not a fan of 20 questions

bolet commented 4 months ago

Ok, so here is the complete debug log since LE booted. LE is minimal and doesn't have pip, plus the filesystem is read-only, so downgrading requests is not an easy option. Note that other https requests are working in Kodi, typically sending https URL to an mp4 file will play it.

MoojMidge commented 4 months ago

LE is minimal and doesn't have pip, plus the filesystem is read-only, so downgrading requests is not an easy option

True, so lets see if it is necessary first.

There is a difference between a debug log and a regular log.

To get the required information regarding which modules are being loaded you need a debug log.

https://kodi.wiki/view/Log_file/Easy

Note that other https requests are working in Kodi, typically sending https URL to an mp4 file will play it.

This will depend entirely on how the requests are being made. Your issue is related to the Python requests module.

bolet commented 4 months ago

Indeed, the debug log is much larger, so I rebooted and reproduced and here it is.

MoojMidge commented 4 months ago

Everything looks normal so you are back to this:

Or maybe the certifi module.

Uninstall and reinstall script.module.certifi

For whatever reason ~/.kodi/addons/script.module.certifi/lib/certifi/cacert.pem seems to be borked on your system.

bolet commented 4 months ago

Thanks a lot, it works again! I can't figure out how it got messed up,

I ended up copying files from the git repository, because I couldn't find how to uninstall/reinstall from within LE.