offish / twitchtube

Twitch YouTube bot. Automatically make video compilations of the most viewed Twitch clips and upload them to YouTube using Python 3.
MIT License
540 stars 77 forks source link

Error SSL #71

Closed nikisb closed 2 years ago

nikisb commented 2 years ago

I dont know why, but for some reason when i start script i only get these errors.

twitchtube | 09:16:58 - info: You're running the latest version of twitchtube at 1.6.5 twitchtube | 09:16:58 - info: You're running the latest version of opplast at 1.0.7 twitchtube | 09:16:58 - info: Going to make video featuring 1 streamers/games, that will end up being ~330.0 seconds long twitchtube | 09:16:59 - info: Getting clips for game League of Legends twitchtube | 09:16:59 - clip: Downloading clip with slug: FaithfulOnerousLadiesHotPokket-8Ertpoet8m5S7-xb. twitchtube | 09:16:59 - clip: Saving 'FaithfulOnerousLadiesHotPokket-8Ertpoet8m5S7-xb' as 'FaithfulOnerousLadiesHotPokket8Ertpoet8m5S7xb.mp4'. Traceback (most recent call last): File "C:\Users\Nikola\Downloads\twitchtube-1.6.5\twitchtube-1.6.5\main.py", line 80, in <module> make_video(**parameters) File "C:\Users\Nikola\Downloads\twitchtube-1.6.5\twitchtube-1.6.5\twitchtube\video.py", line 147, in make_video names += download_clips(batch, path, oauth_token, client_id) File "C:\Users\Nikola\Downloads\twitchtube-1.6.5\twitchtube-1.6.5\twitchtube\clips.py", line 187, in download_clips download_clip(data[clip]["url"], path, oauth_token, client_id) File "C:\Users\Nikola\Downloads\twitchtube-1.6.5\twitchtube-1.6.5\twitchtube\clips.py", line 81, in download_clip urllib.request.urlretrieve(mp4_url, output_path, reporthook=get_progress) File "C:\Users\Nikola\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 239, in urlretrieve with contextlib.closing(urlopen(url, data)) as fp: File "C:\Users\Nikola\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 214, in urlopen return opener.open(url, data, timeout) File "C:\Users\Nikola\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 517, in open response = self._open(req, data) File "C:\Users\Nikola\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 534, in _open result = self._call_chain(self.handle_open, protocol, protocol + File "C:\Users\Nikola\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 494, in _call_chain result = func(*args) File "C:\Users\Nikola\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 1389, in https_open return self.do_open(http.client.HTTPSConnection, req, File "C:\Users\Nikola\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 1315, in do_open h = http_class(host, timeout=req.timeout, **http_conn_args) File "C:\Users\Nikola\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1396, in __init__ context = ssl._create_default_https_context() File "C:\Users\Nikola\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 750, in create_default_context context.load_default_certs(purpose) File "C:\Users\Nikola\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 574, in load_default_certs self._load_windows_store_certs(storename, purpose) File "C:\Users\Nikola\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 566, in _load_windows_store_certs self.load_verify_locations(cadata=certs) ssl.SSLError: [ASN1] nested asn1 error (_ssl.c:4174)

nikisb commented 2 years ago

Picture of a problem https://imgur.com/7SqqEiT

ignisc4t commented 2 years ago

try to run it on administrator privilege, cmd / powershell. look like twitchtube cannot located the cert needed. or I don't know.

offish commented 2 years ago

I have no idea what you could do to fix this

ignisc4t commented 2 years ago

try this one :

In the file "C:\Users\Nikola\AppData\Local\Programs\Python\Python39\lib\ssl.py", try ~removing~ commenting (#) the two lines (at approximately line 470) starting with:

if certs: self.load_verify_locations(cadata=certs)

credit here : https://stackoverflow.com/questions/64303580/error-launching-jupyter-notebook-ssl-sslerror-asn1-nested-asn1-error

edit: updated the comment to suit @nikisb ssl.py path

ignisc4t commented 2 years ago

the first one for the user machine, now another thing to test for twitchtube scripts :

Loading cadata in PEM format results in a nested asn1 error. Workaround is to convert cadata to unicode.

Minimum code for reproducing the issue:

>>>import ssl
>>> with open('ca.crt') as f:
...     ca_crt = f.read()
...
>>> c = ssl.create_default_context()
>>> c.load_verify_locations(cadata=ca_crt)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ssl.SSLError: nested asn1 error (_ssl.c:2902)

With workaround to make it work:

>>>import ssl
>>> with open('ca.crt') as f:
...     ca_crt = f.read()
...
>>> c = ssl.create_default_context()
>>> c.load_verify_locations(cadata=unicode(ca_crt))

The issue is annoying as the documentation explicitly states cadata to be "either an ASCII string of one or more PEM-encoded certificates...". Furthermore the unicode function is not present in Python 3.x, making the workaround version-dependent.

from : https://bugs.python.org/issue37079