Added a URL shortening method that hits the is.gd API, random comments sprinkled throughout - coming along nicely. Perhaps fallbacks should be provided for when the is.gd API limit is reached?
This commit is contained in:
parent
9a13b0ae3f
commit
10c32e427c
1 changed files with 6 additions and 0 deletions
6
tango.py
6
tango.py
|
|
@ -11,6 +11,7 @@ try:
|
||||||
except:
|
except:
|
||||||
print "Tango requires the simplejson library to work. http://www.undefined.org/python/"
|
print "Tango requires the simplejson library to work. http://www.undefined.org/python/"
|
||||||
|
|
||||||
|
# Should really deprecate httplib2 at some point...
|
||||||
try:
|
try:
|
||||||
import httplib2
|
import httplib2
|
||||||
except:
|
except:
|
||||||
|
|
@ -41,6 +42,11 @@ class setup:
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def shortenURL(self, url_to_shorten):
|
||||||
|
# Perhaps we should have fallbacks here in case the is.gd API limit gets hit? Maybe allow them to set the host?
|
||||||
|
shortURL = urllib2.urlopen("http://is.gd/api.php?" + urllib.urlencode({"longurl": url_to_shorten})).read()
|
||||||
|
return shortURL
|
||||||
|
|
||||||
def constructApiURL(self, base_url, params):
|
def constructApiURL(self, base_url, params):
|
||||||
queryURL = base_url
|
queryURL = base_url
|
||||||
questionMarkUsed = False
|
questionMarkUsed = False
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue