fix python2

This commit is contained in:
python2-kod
2024-02-17 07:11:04 +01:00
parent f4bc2c98a8
commit a17bca7bf8
73 changed files with 35 additions and 21 deletions
+6 -2
View File
@@ -4,7 +4,11 @@
# ------------------------------------------------------------
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 platformcode import logger, config
@@ -66,7 +70,7 @@ def genres(item):
data_page = get_data(item.url)
args = data_page['props']['genres']
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)
return itemlist
Executable → Regular
View File
+22 -17
View File
@@ -40,13 +40,28 @@ class CipherSuiteAdapter(HTTPAdapter):
self.ssl_ciphers = ssl_ciphers
super(CipherSuiteAdapter, self).__init__(**kwargs)
if override_dns:
# hack[3/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[2/3] patch urllib3 create connection with custom function
connection.create_connection = CipherSuiteAdapter.override_dns_connection
connection.original_create_connection = connection.create_connection
connection.create_connection = override_dns_connection
def flushDns(domain, **kwargs):
del db['dnscache'][domain]
def getIp(domain):
def getIp(self, domain):
cache = db['dnscache'].get(domain, {})
ip = None
if type(cache) != dict or (cache.get('datetime') and
@@ -60,7 +75,7 @@ class CipherSuiteAdapter(HTTPAdapter):
# IPv6 address
if ':' in ip:
ip = '[' + ip + ']'
CipherSuiteAdapter.writeToCache(domain, ip)
self.writeToCache(domain, ip)
except Exception:
logger.error('Failed to resolve hostname, fallback to normal dns')
import traceback
@@ -70,7 +85,7 @@ class CipherSuiteAdapter(HTTPAdapter):
logger.info('Cache DNS: ' + domain + ' = ' + str(ip))
return ip
def writeToCache(domain, ip):
def writeToCache(self, domain, ip):
db['dnscache'][domain] = {'ip': ip, 'datetime': current_date}
def init_poolmanager(self, *pool_args, **pool_kwargs):
@@ -93,16 +108,6 @@ class CipherSuiteAdapter(HTTPAdapter):
logger.info('Flushing dns cache for ' + domain)
CipherSuiteAdapter.flushDns(domain, **kwargs)
return self.send(request, flushedDns=True, **kwargs)
# hack[3/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 = 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)
except Exception as e:
logger.error(e)
raise e
Executable → Regular
View File
View File
View File
View File
View File
View File
Executable → Regular
View File
View File
View File
Executable → Regular
View File
Executable → Regular
View File
View File
Executable → Regular
View File
View File
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
+7 -2
View File
@@ -1,5 +1,10 @@
# -*- 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 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]
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
#
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File