Add URL shortening method in googletools

This commit is contained in:
Klaus-Uwe Mitterer 2017-03-13 19:59:25 +01:00
parent ee9c3426ff
commit 294f9f08d1

8
googletools/__init__.py Normal file
View file

@ -0,0 +1,8 @@
import pyshorteners
def shortURL(url):
try:
pyshorteners.Shortener('Google', api_key=setuptools.getSetting("Google", "googl")).short(url)
except pyshorteners.exceptions.ShorteningErrorException as e:
print("Error handling %s" % url)
raise