From b596f42b7ee8817d017db7efa50264a8e92b095c Mon Sep 17 00:00:00 2001 From: r4sas Date: Wed, 18 Sep 2019 13:46:30 +0000 Subject: [PATCH] fix response handler (closes #19) Signed-off-by: r4sas --- pbincli/actions.py | 1 + pbincli/api.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pbincli/actions.py b/pbincli/actions.py index 1eaaa4b..92677fa 100644 --- a/pbincli/actions.py +++ b/pbincli/actions.py @@ -73,6 +73,7 @@ def send(args, api_client, settings=None): PBinCLIError("Something went wrong...\nError: Empty response.") if args.short: + print("\nQuerying URL shortening service...") shortener.getlink("{}?{}#{}".format( settings['server'], result['id'], diff --git a/pbincli/api.py b/pbincli/api.py index 37ad4cf..858d19b 100644 --- a/pbincli/api.py +++ b/pbincli/api.py @@ -125,7 +125,7 @@ class Shortener: else: response = result.json() - if {'status', 'code', 'message'} <= set(response.keys()): + if {'status', 'statusCode', 'message'} <= set(response.keys()): if response['status'] == 'fail': PBinCLIError("YOURLS: Received error from API: {}".format(response['message'])) if not 'shorturl' in response: @@ -133,7 +133,7 @@ class Shortener: else: print("Short Link:\t{}".format(response['shorturl'])) else: - PBinCLIError("YOURLS: No status, code and message fields in response! Received:\n{}".format(response)) + PBinCLIError("YOURLS: No status, statusCode or message fields in response! Received:\n{}".format(response)) elif self.api == 'clckru': # from urllib.parse import quote_plus