2010-01-17 04:24:36 +00:00
|
|
|
import re
|
|
|
|
import urllib2
|
|
|
|
|
|
|
|
from util import hook
|
|
|
|
|
|
|
|
|
2010-03-12 00:19:36 +00:00
|
|
|
tinyurl_re = (r'http://(?:www\.)?tinyurl.com/([A-Za-z0-9\-]+)',
|
|
|
|
re.IGNORECASE)
|
2010-01-17 04:24:36 +00:00
|
|
|
|
|
|
|
|
2010-03-12 00:19:36 +00:00
|
|
|
@hook.regex(*tinyurl_re)
|
|
|
|
def tinyurl(match):
|
|
|
|
try:
|
|
|
|
return urllib2.urlopen(match.group()).url.strip()
|
|
|
|
except urllib2.URLError:
|
|
|
|
pass
|