From c425d86ed634619b41db7c12eefac3df35086cc3 Mon Sep 17 00:00:00 2001 From: r4sas Date: Fri, 20 Sep 2019 06:00:08 +0000 Subject: [PATCH] [shortener] remove not completed bitly support code Anyone can request to add support later, so for now I removing that code due to lack of use. Signed-off-by: r4sas --- pbincli/api.py | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/pbincli/api.py b/pbincli/api.py index 9404a0e..fc1da15 100644 --- a/pbincli/api.py +++ b/pbincli/api.py @@ -229,32 +229,3 @@ class Shortener: print("Short Link:\t{}".format(result.text)) except Exception as ex: PBinCLIError("cutt.ly: unexcepted behavior: {}".format(ex)) - - - # [WIP] That code needs testing. API requires username and apiKey or accessToken to work. - def _bitly(self, url): - request = {'url': url} - headers = {'X-Requested-With': 'XMLHttpRequest'} - - try: - result = self.session.post( - url = "https://bitly.com/", - headers = headers, - proxies = self.proxy, - data = request) - response = result.json() - if response['data'] and response['status_code'] == 200: - print("Short Link:\t{}".format(response['data']['anon_shorten']['link'])) - elif response['status_txt']: - errcode = response['status_txt'] or 'DEFAULT' - friendlyError = { - 'RATE_LIMIT_EXCEEDED': 'Whoa - you\'ve exceeded your quota. Create a free account to keep shortening.', - 'INVALID_ARG_URL': 'Unable to shorten that link. It is not a valid url.', - 'INVALID_ARG_LONGURL': 'Unable to shorten that link. It is not a valid url.', - 'ALREADY_A_BITLY_LINK': 'That is already a Bitly link', - 'UNKNOWN_ERROR': 'Woops. Something went wrong. Please try again.', - 'DEFAULT': 'An error occurred' - } - PBinCLIError("bitly: got error from API: {}".format(friendlyError[errcode])) - except Exception as ex: - PBinCLIError("bitly: unexcepted behavior: {}".format(ex))