This commit is contained in:
spline 2012-12-23 16:37:42 -05:00
parent 72b3af33a4
commit 471f54fb87
1 changed files with 4 additions and 5 deletions

View File

@ -278,11 +278,10 @@ class Tweety(callbacks.Plugin):
def _expandLinks(self, tweet):
# if not surl.startswith('http://') and not surl.startswith('https://'):
_tco_link_re = re.compile(u'http://t.co/[a-zA-Z0-9]+')
try:
req_url = 'http://api.longurl.org/v2/expand?format=json&url=' + qurl
req = urllib2.Request(req_url, headers={'User-Agent': 'Python-longurl/1.0'})
lookup = json.loads(urllib2.urlopen(req).read())
return lookup.get('long-url', None)
req_url = 'http://api.longurl.org/v2/expand?format=json&url=' + qurl
req = urllib2.Request(req_url, headers={'User-Agent': 'Python-longurl/1.0'})
lookup = json.loads(urllib2.urlopen(req).read())
return lookup.get('long-url', None)
#def re_encode(input_string, decoder = 'utf-8', encoder = 'utf=8'):
#try: