Merge pull request #470 from python2-kod/stable
correzioni per kodi su raspberry pi
This commit is contained in:
@@ -4,7 +4,11 @@
|
|||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
import json, re, sys
|
import json, re, sys
|
||||||
import urllib.parse
|
PY3 = False
|
||||||
|
if sys.version_info[0] >= 3: PY3 = True
|
||||||
|
|
||||||
|
if PY3: import urllib.parse as urllib_parse
|
||||||
|
else: import urlparse as urllib_parse
|
||||||
|
|
||||||
from core import support, channeltools, httptools, jsontools
|
from core import support, channeltools, httptools, jsontools
|
||||||
from platformcode import logger, config
|
from platformcode import logger, config
|
||||||
@@ -66,7 +70,7 @@ def genres(item):
|
|||||||
data_page = get_data(item.url)
|
data_page = get_data(item.url)
|
||||||
args = data_page['props']['genres']
|
args = data_page['props']['genres']
|
||||||
for arg in args:
|
for arg in args:
|
||||||
itemlist.append(item.clone(title=support.typo(arg['name'], 'bold'), url=host+'/browse/genre?g='+urllib.parse.quote(arg['name']), action='peliculas', genre=True))
|
itemlist.append(item.clone(title=support.typo(arg['name'], 'bold'), url=host+'/browse/genre?g='+urllib_parse.quote(arg['name']), action='peliculas', genre=True))
|
||||||
support.thumb(itemlist, genre=True)
|
support.thumb(itemlist, genre=True)
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|||||||
Executable → Regular
+26
-20
@@ -32,21 +32,37 @@ current_date = datetime.datetime.now()
|
|||||||
CIPHERS = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384"
|
CIPHERS = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384"
|
||||||
|
|
||||||
class CipherSuiteAdapter(HTTPAdapter):
|
class CipherSuiteAdapter(HTTPAdapter):
|
||||||
# hack[1/3] to patch urllib3 create connection
|
|
||||||
original_create_connection = connection.create_connection
|
|
||||||
|
|
||||||
def __init__(self, domain, ssl_options=ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1, override_dns = True, ssl_ciphers = CIPHERS, **kwargs):
|
def __init__(self, domain, ssl_options=ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1, override_dns = True, ssl_ciphers = CIPHERS, **kwargs):
|
||||||
self.ssl_options = ssl_options
|
self.ssl_options = ssl_options
|
||||||
self.ssl_ciphers = ssl_ciphers
|
self.ssl_ciphers = ssl_ciphers
|
||||||
super(CipherSuiteAdapter, self).__init__(**kwargs)
|
super(CipherSuiteAdapter, self).__init__(**kwargs)
|
||||||
if override_dns:
|
if override_dns:
|
||||||
# hack[2/3] patch urllib3 create connection with custom function
|
|
||||||
connection.create_connection = CipherSuiteAdapter.override_dns_connection
|
# hack[1/3] to patch urllib3 create connection
|
||||||
|
if not hasattr(connection, 'original_create_connection'):
|
||||||
|
connection.original_create_connection = connection.create_connection
|
||||||
|
|
||||||
|
# hack[2/3] function that use doh for host name resolution
|
||||||
|
def override_dns_connection(address, *args, **kwargs):
|
||||||
|
"""Wrap urllib3's create_connection to resolve the name elsewhere"""
|
||||||
|
# resolve hostname to an ip address; use your own
|
||||||
|
# resolver here, as otherwise the system resolver will be used.
|
||||||
|
host, port = address
|
||||||
|
hostname = self.getIp(host)
|
||||||
|
if not hostname:
|
||||||
|
hostname = host #fallback
|
||||||
|
logger.debug("Override dns failed, fallback to normal dns resolver")
|
||||||
|
|
||||||
|
return connection.original_create_connection((hostname, port), *args, **kwargs)
|
||||||
|
|
||||||
|
# hack[3/3] patch urllib3 create connection with custom function
|
||||||
|
connection.create_connection = override_dns_connection
|
||||||
|
|
||||||
def flushDns(domain, **kwargs):
|
def flushDns(domain, **kwargs):
|
||||||
del db['dnscache'][domain]
|
del db['dnscache'][domain]
|
||||||
|
|
||||||
def getIp(domain):
|
def getIp(self, domain):
|
||||||
cache = db['dnscache'].get(domain, {})
|
cache = db['dnscache'].get(domain, {})
|
||||||
ip = None
|
ip = None
|
||||||
if type(cache) != dict or (cache.get('datetime') and
|
if type(cache) != dict or (cache.get('datetime') and
|
||||||
@@ -60,7 +76,7 @@ class CipherSuiteAdapter(HTTPAdapter):
|
|||||||
# IPv6 address
|
# IPv6 address
|
||||||
if ':' in ip:
|
if ':' in ip:
|
||||||
ip = '[' + ip + ']'
|
ip = '[' + ip + ']'
|
||||||
CipherSuiteAdapter.writeToCache(domain, ip)
|
self.writeToCache(domain, ip)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.error('Failed to resolve hostname, fallback to normal dns')
|
logger.error('Failed to resolve hostname, fallback to normal dns')
|
||||||
import traceback
|
import traceback
|
||||||
@@ -70,7 +86,7 @@ class CipherSuiteAdapter(HTTPAdapter):
|
|||||||
logger.info('Cache DNS: ' + domain + ' = ' + str(ip))
|
logger.info('Cache DNS: ' + domain + ' = ' + str(ip))
|
||||||
return ip
|
return ip
|
||||||
|
|
||||||
def writeToCache(domain, ip):
|
def writeToCache(self, domain, ip):
|
||||||
db['dnscache'][domain] = {'ip': ip, 'datetime': current_date}
|
db['dnscache'][domain] = {'ip': ip, 'datetime': current_date}
|
||||||
|
|
||||||
def init_poolmanager(self, *pool_args, **pool_kwargs):
|
def init_poolmanager(self, *pool_args, **pool_kwargs):
|
||||||
@@ -93,16 +109,6 @@ class CipherSuiteAdapter(HTTPAdapter):
|
|||||||
logger.info('Flushing dns cache for ' + domain)
|
logger.info('Flushing dns cache for ' + domain)
|
||||||
CipherSuiteAdapter.flushDns(domain, **kwargs)
|
CipherSuiteAdapter.flushDns(domain, **kwargs)
|
||||||
return self.send(request, flushedDns=True, **kwargs)
|
return self.send(request, flushedDns=True, **kwargs)
|
||||||
|
except Exception as e:
|
||||||
# hack[3/3] function that use doh for host name resolution
|
logger.error(e)
|
||||||
def override_dns_connection(address, *args, **kwargs):
|
raise e
|
||||||
"""Wrap urllib3's create_connection to resolve the name elsewhere"""
|
|
||||||
# resolve hostname to an ip address; use your own
|
|
||||||
# resolver here, as otherwise the system resolver will be used.
|
|
||||||
host, port = address
|
|
||||||
hostname = CipherSuiteAdapter.getIp(host)
|
|
||||||
if not hostname:
|
|
||||||
hostname = host #fallback
|
|
||||||
logger.debug("Override dns failed, fallback to normal dns resolver")
|
|
||||||
|
|
||||||
return CipherSuiteAdapter.original_create_connection((hostname, port), *args, **kwargs)
|
|
||||||
|
|||||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
+7
-2
@@ -1,5 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import urllib.parse
|
import sys
|
||||||
|
PY3 = False
|
||||||
|
if sys.version_info[0] >= 3: PY3 = True
|
||||||
|
|
||||||
|
if PY3: import urllib.parse as urllib
|
||||||
|
else: import urllib
|
||||||
import ast
|
import ast
|
||||||
import xbmc
|
import xbmc
|
||||||
|
|
||||||
@@ -35,7 +40,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
|
|||||||
|
|
||||||
# scws_id = urlparse(server_url).path.split('/')[-1]
|
# scws_id = urlparse(server_url).path.split('/')[-1]
|
||||||
masterPlaylistParams = ast.literal_eval(iframeParams[0])
|
masterPlaylistParams = ast.literal_eval(iframeParams[0])
|
||||||
url = iframeParams[1] + '?{}&n=1'.format(urllib.parse.urlencode(masterPlaylistParams))
|
url = iframeParams[1] + '?{}&n=1'.format(urllib.urlencode(masterPlaylistParams))
|
||||||
|
|
||||||
# info = support.match(url, patron=r'LANGUAGE="([^"]+)",\s*URI="([^"]+)|(http.*?rendition=(\d+)[^\s]+)').matches
|
# info = support.match(url, patron=r'LANGUAGE="([^"]+)",\s*URI="([^"]+)|(http.*?rendition=(\d+)[^\s]+)').matches
|
||||||
#
|
#
|
||||||
|
|||||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Reference in New Issue
Block a user