Print raw response when JSON fails to parse

If the response to the Tautulli API fails to parse correctly include the 
raw output in the message to make it easier to diagnose when the 
response isn't actually raw JSON from a Tautulli server (e.g. a proxy 
server).
This commit is contained in:
Landon Abney 2019-10-27 20:04:36 -07:00
parent 645c43708a
commit 66ac37b34e
No known key found for this signature in database
GPG Key ID: 3AEE8541ED08A7D9

View File

@ -268,7 +268,9 @@ class Tautulli:
try:
response_json = response.json()
except ValueError:
print("Failed to parse json response for Tautulli API cmd '{}'".format(cmd))
print(
"Failed to parse json response for Tautulli API cmd '{}': {}"
.format(cmd, response.content))
return
if response_json['response']['result'] == 'success':