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

@ -86,8 +86,12 @@ def soundcloud_download(token, callback_url, api_key, track_id):
auth=requests.auth.HTTPBasicAuth(api_key, ""),
)
re.raise_for_status()
try:
response = re.content.decode()
except (UnicodeDecodeError, AttributeError):
response = re.content
f = json.loads(
re.content
response
) # Read the response from the media API to get the file id
obj["fileid"] = f["id"]
else:
@ -203,8 +207,12 @@ def podcast_download(
auth=requests.auth.HTTPBasicAuth(api_key, ""),
)
re.raise_for_status()
try:
response = re.content.decode()
except (UnicodeDecodeError, AttributeError):
response = re.content
f = json.loads(
re.content
response
) # Read the response from the media API to get the file id
obj["fileid"] = f["id"]
obj["status"] = 1