Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -Naur old/resources/lib/pandoki/pandoki.py plugin.audio.pandoki/resources/lib/pandoki/pandoki.py
- --- old/resources/lib/pandoki/pandoki.py 2015-01-02 08:14:17.152966502 +0100
- +++ plugin.audio.pandoki/resources/lib/pandoki/pandoki.py 2015-01-02 08:07:13.588677898 +0100
- @@ -2,6 +2,15 @@
- import xbmc, xbmcaddon, xbmcgui, xbmcplugin, xbmcvfs
- import asciidamnit, musicbrainzngs, pithos
- +try:
- + import urllib3
- + import urllib3.contrib.pyopenssl
- + urllib3.contrib.pyopenssl.inject_into_urllib3()
- + _urllib3 = True
- +except ImportError:
- + _urllib3 = False
- + pass
- +
- from mutagen.mp3 import MP3
- from mutagen.easyid3 import EasyID3
- from mutagen.easymp4 import EasyMP4
- @@ -56,6 +65,11 @@
- self.prof = Val('prof')
- self.wait = { 'auth' : 0, 'stations' : 0, 'flush' : 0, 'scan' : 0, 'next' : 0 }
- self.silent = xbmc.translatePath("special://home/addons/%s/resources/media/silent.m4a" % _id)
- +
- + if (Val('sni') == 'true'):
- + self.sni = True
- + else:
- + self.sni = False
- musicbrainzngs.set_useragent("xbmc.%s" % _id, Val('version'))
- xbmcvfs.mkdirs(xbmc.translatePath(Val('cache')).decode("utf-8"))
- @@ -79,6 +93,21 @@
- return open
- + def ProxySNI(self):
- + proxy = Val('proxy')
- +
- + if proxy == '0': # Global
- + open = urllib3.PoolManager()
- +
- + elif proxy == '1': # None
- + open = urllib3.PoolManager()
- +
- + elif proxy == '2': # Custom
- + http = "http://%s:%s@%s:%s" % (Val('proxy_user'), Val('proxy_pass'), Val('proxy_host'), Val('proxy_port'))
- + open = urllib3.ProxyManager(http)
- +
- + return open
- +
- def Auth(self):
- p = Val('prof')
- @@ -89,7 +118,10 @@
- if time.time() < self.wait['auth']: return True
- - self.pithos.set_url_opener(self.Proxy())
- + if (self.sni):
- + self.pithos.set_url_opener(self.ProxySNI(), True)
- + else:
- + self.pithos.set_url_opener(self.Proxy(), False)
- try: self.pithos.connect(Val('one' + p), Val('username' + p), Val('password' + p))
- except pithos.PithosError:
- @@ -102,6 +134,13 @@
- def Login(self):
- + if (self.sni):
- + if not (_urllib3):
- + if xbmcgui.Dialog().yesno(Val('name'), 'SNI Support not found', 'Please install: pyOpenSSL/ndg-httpsclient/pyasn1', 'Check Settings?'):
- + xbmcaddon.Addon().openSettings()
- + else:
- + exit()
- +
- while not self.Auth():
- if xbmcgui.Dialog().yesno(Val('name'), ' Login Failed', 'Bad User / Pass / Proxy', ' Check Settings?'):
- xbmcaddon.Addon().openSettings()
- diff -Naur old/resources/lib/pithos/pithos.py plugin.audio.pandoki/resources/lib/pithos/pithos.py
- --- old/resources/lib/pithos/pithos.py 2015-01-02 08:14:17.152966502 +0100
- +++ plugin.audio.pandoki/resources/lib/pithos/pithos.py 2015-01-01 21:42:53.382838813 +0100
- @@ -85,6 +85,7 @@
- def __init__(self):
- self.opener = urllib2.build_opener()
- self.stations = []
- + self.sni = False
- pass
- @@ -125,19 +126,27 @@
- if blowfish:
- data = self.pandora_encrypt(data)
- - try:
- - req = urllib2.Request(url, data, {'User-agent': USER_AGENT, 'Content-type': 'text/plain'})
- - response = self.opener.open(req, timeout=HTTP_TIMEOUT)
- - text = response.read()
- - except urllib2.HTTPError as e:
- - logging.error("HTTP error: %s", e)
- - raise PithosNetError(str(e))
- - except urllib2.URLError as e:
- - logging.error("Network error: %s", e)
- - if e.reason[0] == 'timed out':
- - raise PithosTimeout("Network error", submsg="Timeout")
- - else:
- - raise PithosNetError("Network error", submsg=e.reason[1])
- + if self.sni:
- + try:
- + response = self.opener.urlopen('POST', url, headers={'User-agent': USER_AGENT, 'Content-type': 'text/plain'}, body=data)
- + text = response.data
- + except:
- + logging.error("urllib3 error")
- + raise PithosNetError('urllib3 error')
- + else:
- + try:
- + req = urllib2.Request(url, data, {'User-agent': USER_AGENT, 'Content-type': 'text/plain'})
- + response = self.opener.open(req, timeout=HTTP_TIMEOUT)
- + text = response.read()
- + except urllib2.HTTPError as e:
- + logging.error("HTTP error: %s", e)
- + raise PithosNetError(str(e))
- + except urllib2.URLError as e:
- + logging.error("Network error: %s", e)
- + if e.reason[0] == 'timed out':
- + raise PithosTimeout("Network error", submsg="Timeout")
- + else:
- + raise PithosNetError("Network error", submsg=e.reason.strerror)
- logging.debug(text)
- @@ -179,7 +188,8 @@
- return tree['result']
- - def set_url_opener(self, opener):
- + def set_url_opener(self, opener, sni):
- + self.sni = sni
- self.opener = opener
- diff -Naur old/resources/settings.xml plugin.audio.pandoki/resources/settings.xml
- --- old/resources/settings.xml 2015-01-02 08:14:17.144966647 +0100
- +++ plugin.audio.pandoki/resources/settings.xml 2015-01-01 21:42:53.382838813 +0100
- @@ -12,7 +12,8 @@
- <setting id="password2" type="text" label="Password" visible="eq(-8,2)" option="hidden"/>
- <setting id="one2" type="bool" label="Pandora One" default="false" visible="eq(-9,2)"/>
- <setting type="sep"/>
- - <setting id="proxy" type="enum" label="Use Proxy" default="0" values="Global|None|Custom"/>
- + <setting id="sni" type="bool" label="SNI Support" default="false"/>
- + <setting id="proxy" type="enum" label="Use Proxy" default="0" values="Global|None|Custom"/>
- <setting id="proxy_host" type="text" label="Server" visible="eq(-1,2)"/>
- <setting id="proxy_port" type="number" label="Port" visible="eq(-2,2)"/>
- <setting id="proxy_user" type="text" label="Username" visible="eq(-3,2)"/>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement