Ensure all json loads calls use strings

This commit is contained in:
Kyle Robbertze 2020-05-04 13:24:57 +02:00
parent cf3b9782ac
commit e0e4d4c87f
7 changed files with 36 additions and 4 deletions

View file

@ -27,6 +27,10 @@ class CuePointAnalyzer(Analyzer):
command = [CuePointAnalyzer.SILAN_EXECUTABLE, '-b', '-F', '0.99', '-f', 'JSON', '-t', '1.0', filename]
try:
results_json = subprocess.check_output(command, stderr=subprocess.STDOUT, close_fds=True)
try:
results_json = results_json.decode()
except (UnicodeDecodeError, AttributeError):
pass
silan_results = json.loads(results_json)
# Defensive coding against Silan wildly miscalculating the cue in and out times:

View file

@ -157,6 +157,10 @@ class MessageListener:
We avoid cascading failure this way.
'''
try:
try:
body = body.decode()
except (UnicodeDecodeError, AttributeError):
pass
msg_dict = json.loads(body)
api_key = msg_dict["api_key"]
callback_url = msg_dict["callback_url"]