plugin.video.youtube icon indicating copy to clipboard operation
plugin.video.youtube copied to clipboard

YouTube addon don't use Kodi's proxy

Open xmha97 opened this issue 4 years ago • 2 comments

Hello, Please see this issue: https://github.com/xbmc/xbmc/issues/17729

xmha97 avatar Apr 22 '20 11:04 xmha97

Some notes, if someone wants to tackle this:

  • Some requests in the add-on seem to be done here, there might be other places:
    https://github.com/jdf76/plugin.video.youtube/blob/b63c165cb6363dd26ef0fc5f1e4e1f00af5df3f9/resources/lib/youtube_plugin/youtube/client/youtube.py#L1111-L1123

  • There's a proxies parameter to requests functions that lets you specify HTTP(S) proxies: https://requests.readthedocs.io/en/master/user/advanced/#proxies

  • The same parameter lets you use SOCKS proxies: https://requests.readthedocs.io/en/master/user/advanced/#socks But for this to work you need the PySocks library as a dependency: script.module.pysocks (it's in the official Kodi repo)

  • Finally, you can query the Kodi system proxy settings using the JSON-RPC API.
    The setting IDs can be seen here: https://github.com/xbmc/xbmc/blob/master/system/settings/settings.xml#L2756-L2825

doko-desuka avatar Apr 23 '20 23:04 doko-desuka

Thanks for the solution provided by doko-desuka! On my current version 7.0.3.2+matrix+1, seems like the request is abstracted into resources/lib/youtube_plugin/kodion/network/requests.py, in function def request(self,url, method='GET', ...)

        if verify is None:
            verify = self._verify
        if allow_redirects is None:
            allow_redirects = True

        # add my hard-coded proxy settings here
        proxies = {
          'http': 'http://192.168.1.7:10809',
          'https': 'http://192.168.1.7:10809',
        }
        response = None
        try:
            response = self._session.request(method, url,
                                             params=params,
                                             data=data,
                                             headers=headers,
                                             cookies=cookies,
                                             files=files,
                                             auth=auth,
                                             timeout=timeout,
                                             allow_redirects=allow_redirects,
                                             proxies=proxies,
                                             hooks=hooks,
                                             stream=stream,
                                             verify=verify,
                                             cert=cert,
                                             json=json)

hak0 avatar Mar 17 '24 07:03 hak0