xbmcbackup/resources/lib/tinyurl.py

13 lines
368 B
Python
Raw Permalink Normal View History

2019-11-25 22:19:57 +01:00
# this is duplicated in snipppets of code from all over the web, credit to no one
# in particular - to all those that have gone before me!
2019-11-25 22:56:59 +01:00
from future.moves.urllib.request import urlopen
2017-01-30 19:51:36 +01:00
def shorten(aUrl):
tinyurl = 'http://tinyurl.com/api-create.php?url='
2019-08-27 22:03:43 +02:00
req = urlopen(tinyurl + aUrl)
2017-01-30 19:51:36 +01:00
data = req.read()
2019-11-25 22:19:57 +01:00
# should be a tiny url
2017-01-30 19:51:36 +01:00
return str(data)