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

View File

@@ -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

0
core/httptools.py Executable file → Normal file
View File

View File

@@ -40,13 +40,28 @@ class CipherSuiteAdapter(HTTPAdapter):
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[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 # 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): 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 +75,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 +85,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 +108,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)

0
lib/babelfish/__init__.py Executable file → Normal file
View File

0
lib/babelfish/converters/__init__.py Executable file → Normal file
View File

0
lib/babelfish/converters/alpha2.py Executable file → Normal file
View File

0
lib/babelfish/converters/alpha3b.py Executable file → Normal file
View File

0
lib/babelfish/converters/alpha3t.py Executable file → Normal file
View File

0
lib/babelfish/converters/countryname.py Executable file → Normal file
View File

0
lib/babelfish/converters/name.py Executable file → Normal file
View File

0
lib/babelfish/converters/opensubtitles.py Executable file → Normal file
View File

0
lib/babelfish/converters/scope.py Executable file → Normal file
View File

0
lib/babelfish/converters/type.py Executable file → Normal file
View File

0
lib/babelfish/country.py Executable file → Normal file
View File

0
lib/babelfish/data/iso-3166-1.txt Executable file → Normal file
View File

0
lib/babelfish/data/iso-639-3.tab Executable file → Normal file
View File

0
lib/babelfish/data/iso15924-utf8-20131012.txt Executable file → Normal file
View File

0
lib/babelfish/data/opensubtitles_languages.txt Executable file → Normal file
View File

0
lib/babelfish/exceptions.py Executable file → Normal file
View File

0
lib/babelfish/language.py Executable file → Normal file
View File

0
lib/babelfish/script.py Executable file → Normal file
View File

0
lib/future/backports/test/pystone.py Executable file → Normal file
View File

0
lib/rebulk/__init__.py Executable file → Normal file
View File

0
lib/rebulk/__version__.py Executable file → Normal file
View File

0
lib/rebulk/builder.py Executable file → Normal file
View File

0
lib/rebulk/chain.py Executable file → Normal file
View File

0
lib/rebulk/debug.py Executable file → Normal file
View File

0
lib/rebulk/formatters.py Executable file → Normal file
View File

0
lib/rebulk/introspector.py Executable file → Normal file
View File

0
lib/rebulk/loose.py Executable file → Normal file
View File

0
lib/rebulk/match.py Executable file → Normal file
View File

0
lib/rebulk/pattern.py Executable file → Normal file
View File

0
lib/rebulk/processors.py Executable file → Normal file
View File

0
lib/rebulk/rebulk.py Executable file → Normal file
View File

0
lib/rebulk/remodule.py Executable file → Normal file
View File

0
lib/rebulk/rules.py Executable file → Normal file
View File

0
lib/rebulk/toposort.py Executable file → Normal file
View File

0
lib/rebulk/utils.py Executable file → Normal file
View File

0
lib/rebulk/validators.py Executable file → Normal file
View File

0
servers/clicknupload.py Executable file → Normal file
View File

0
servers/crunchyroll.py Executable file → Normal file
View File

0
servers/debriders/realdebrid.json Executable file → Normal file
View File

0
servers/debriders/realdebrid.py Executable file → Normal file
View File

0
servers/decrypters/adfly.py Executable file → Normal file
View File

0
servers/decrypters/linkbucks.py Executable file → Normal file
View File

0
servers/decrypters/longurl.py Executable file → Normal file
View File

0
servers/facebook.py Executable file → Normal file
View File

0
servers/fastplay.json Executable file → Normal file
View File

0
servers/gamovideo.json Executable file → Normal file
View File

0
servers/gamovideo.py Executable file → Normal file
View File

0
servers/googlevideo.py Executable file → Normal file
View File

0
servers/hugefiles.py Executable file → Normal file
View File

0
servers/mediafire.py Executable file → Normal file
View File

0
servers/mega.py Executable file → Normal file
View File

0
servers/netutv.json Executable file → Normal file
View File

0
servers/netutv.py Executable file → Normal file
View File

0
servers/sendvid.json Executable file → Normal file
View File

0
servers/sendvid.py Executable file → Normal file
View File

9
servers/streamingcommunityws.py Executable file → Normal file
View File

@@ -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
# #

0
servers/torrent.py Executable file → Normal file
View File

0
servers/uploadedto.py Executable file → Normal file
View File

0
servers/uptobox.py Executable file → Normal file
View File

0
servers/vidtodo.json Executable file → Normal file
View File

0
servers/vidtodo.py Executable file → Normal file
View File

0
servers/vidup.json Executable file → Normal file
View File

0
servers/vidup.py Executable file → Normal file
View File

0
servers/vk.json Executable file → Normal file
View File

0
servers/vk.py Executable file → Normal file
View File

0
servers/yourupload.json Executable file → Normal file
View File

0
servers/yourupload.py Executable file → Normal file
View File

0
servers/youtube.json Executable file → Normal file
View File

0
servers/zippyshare.py Executable file → Normal file
View File

0
tests/run.sh Executable file → Normal file
View File