diff --git a/googletools/__init__.py b/httptools/__init__.py similarity index 50% rename from googletools/__init__.py rename to httptools/__init__.py index b4891a9..e0a4da9 100644 --- a/googletools/__init__.py +++ b/httptools/__init__.py @@ -1,8 +1,12 @@ -import setuptools, pyshorteners +import setuptools, pyshorteners, requests + +def longURL(url): + return requests.head(url, allow_redirects=True).url def shortURL(url): try: - return pyshorteners.Shortener('Google', api_key=setuptools.getSetting("Google", "googl")).short(url) + return pyshorteners.Shortener('Google', api_key=setuptools.getSetting("Google", "googl")).short(longURL(url)) except pyshorteners.exceptions.ShorteningErrorException as e: print("Error handling %s" % url) - raise + print(e) + return False