From 294f9f08d184936848a99c8e22879c3f735082c5 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Mon, 13 Mar 2017 19:59:25 +0100 Subject: [PATCH] Add URL shortening method in googletools --- googletools/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 googletools/__init__.py diff --git a/googletools/__init__.py b/googletools/__init__.py new file mode 100644 index 0000000..3a72083 --- /dev/null +++ b/googletools/__init__.py @@ -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