Skip to content

Commit

Permalink
fix [SSL: WRONG_SIGNATURE_TYPE]
Browse files Browse the repository at this point in the history
  • Loading branch information
Belfagor2005 committed Apr 8, 2023
1 parent 677b1c4 commit f927283
Show file tree
Hide file tree
Showing 6 changed files with 897 additions and 32 deletions.
66 changes: 63 additions & 3 deletions usr/lib/enigma2/python/Plugins/Extensions/Filmon/Utils.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 15.02.2023
# 30.03.2023
# a common tips used from Lululla
#
import sys
Expand Down Expand Up @@ -302,7 +302,11 @@ def downloadFile(url, target):
response = urlopen(url, None, 5)
with open(target, 'wb') as output:
# print('response: ', response)
output.write(response.read())
if PY3:
output.write(response.read().decode('utf-8'))
else:
output.write(response.read())
# output.write(response.read())
response.close()
return True
except HTTPError:
Expand Down Expand Up @@ -447,7 +451,7 @@ def checkRedirect(url):
# print("*** check redirect ***")
import requests
from requests.adapters import HTTPAdapter
hdr = {"User-Agent": "Enigma2 - XCForever Plugin"}
hdr = {"User-Agent": "Enigma2 - Enigma2 Plugin"}
x = ""
adapter = HTTPAdapter()
http = requests.Session()
Expand All @@ -461,6 +465,62 @@ def checkRedirect(url):
return str(url)





def checkRedirect2(url):
# print("*** check redirect ***")
import requests
from requests.adapters import HTTPAdapter
# hdr = {"User-Agent": "Enigma2 - Enigma2 Plugin"}
# x = ""
# adapter = HTTPAdapter()
# http = requests.Session()
# http.mount("http://", adapter)
# http.mount("https://", adapter)
# try:
# x = http.get(url, headers=hdr, timeout=15, verify=False, stream=True)
# return str(x.url)
# except Exception as e:
# print(e)
# return str(url)
import ssl
from urllib3 import poolmanager
# class TLSAdapter(requests.adapters.HTTPAdapter):


# def init_poolmanager(self, connections, maxsize, block=False):
# """Create and initialize the urllib3 PoolManager."""
# ctx = ssl.create_default_context()
# ctx.set_ciphers('DEFAULT@SECLEVEL=1')
# self.poolmanager = poolmanager.PoolManager(
# num_pools=connections,
# maxsize=maxsize,
# block=block,
# ssl_version=ssl.PROTOCOL_TLS,
# ssl_context=ctx)

# session = requests.session()
# session.mount('https://', TLSAdapter())
# res = session.get(url)
# return res

class TLSAdapter(requests.adapters.HTTPAdapter):

def init_poolmanager(self, *args, **kwargs):
ctx = ssl.create_default_context()
ctx.set_ciphers('DEFAULT@SECLEVEL=1')
kwargs['ssl_context'] = ctx
return super(TLSAdapter, self).init_poolmanager(*args, **kwargs)

session = requests.session()
session.mount('https://', TLSAdapter())
res = session.get(url)
print('TLSAdapter: ', res)
return res



def freespace():
try:
diskSpace = os.statvfs('/')
Expand Down
57 changes: 57 additions & 0 deletions usr/lib/enigma2/python/Plugins/Extensions/Filmon/cache.py
@@ -0,0 +1,57 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Tulip routine libraries, based on lambda's lamlib
Author Twilight0
License summary below, for more details please read license.txt file
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''


import re
import hashlib


def get(function, timeout=10, *args, **table):
try:
response = None

f = repr(function)
f = re.sub('.+\smethod\s|.+function\s|\sat\s.+|\sof\s.+', '', f)
a = hashlib.md5()
for i in args:
a.update(str(i))
a = str(a.hexdigest())
except:
pass

try:
table = table['table']
except:
table = 'rel_list'

try:
r = function(*args)
if (r is None or r == []) and response is not None:
return response
elif (r is None or r == []):
return r
except:
return

try:
return eval(r.encode('utf-8'))
except:
pass

0 comments on commit f927283

Please sign in to comment.