mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 19:22:45 +01:00
ShrinkUrl & core: Fix encoding issue related to getUrlFd.
This commit is contained in:
parent
5446ac13c5
commit
ab011a6618
@ -29,6 +29,7 @@
|
||||
###
|
||||
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import urllib
|
||||
@ -266,6 +267,8 @@ class ShrinkUrl(callbacks.PluginRegexp):
|
||||
headers['content-type'] = 'application/json'
|
||||
data = json.dumps({'longUrl': url})
|
||||
text = utils.web.getUrl(self._gooApi, data=data, headers=headers)
|
||||
if sys.version_info[0] >= 3 and isinstance(text, bytes):
|
||||
text = text.decode()
|
||||
googl = json.loads(text)['id']
|
||||
if googl:
|
||||
self.db.set('goo', url, googl)
|
||||
|
@ -108,6 +108,8 @@ def getUrlFd(url, headers=None, data=None, timeout=None):
|
||||
a dict and string, respectively, as per urllib2.Request's arguments."""
|
||||
if headers is None:
|
||||
headers = defaultHeaders
|
||||
if sys.version_info[0] >= 3 and isinstance(data, str):
|
||||
data = data.encode()
|
||||
try:
|
||||
if not isinstance(url, urllib2.Request):
|
||||
(scheme, loc, path, query, frag) = urlparse.urlsplit(url)
|
||||
|
Loading…
Reference in New Issue
Block a user