|
|
@ -116,13 +116,13 @@ class Shortener: |
|
|
|
data = request) |
|
|
|
data = request) |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
result.json() |
|
|
|
response = result.json() |
|
|
|
if result['status'] == 'fail' and result['code'] == 'error:keyword': |
|
|
|
if response['status'] == 'fail' and response['code'] == 'error:keyword': |
|
|
|
PBinCLIError("YOURLS: Received error from API: {}".format(result['message'])) |
|
|
|
PBinCLIError("YOURLS: Received error from API: {}".format(response['message'])) |
|
|
|
if not 'shorturl' in result: |
|
|
|
if not 'shorturl' in response: |
|
|
|
PBinCLIError("YOURLS: Unknown error: {}".format(result['message'])) |
|
|
|
PBinCLIError("YOURLS: Unknown error: {}".format(response['message'])) |
|
|
|
|
|
|
|
|
|
|
|
print("Short Link:\t{}".format(result['shorturl'])) |
|
|
|
print("Short Link:\t{}".format(response['shorturl'])) |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
PBinCLIError("YOURLS: Unable parse response. Received (size = {}):\n{}".format(len(result.text), result.text)) |
|
|
|
PBinCLIError("YOURLS: Unable parse response. Received (size = {}):\n{}".format(len(result.text), result.text)) |
|
|
|
|
|
|
|
|
|
|
|