Skip to content

Commit c1bec04

Browse files
committed
Update ampache.py
1 parent 3bf2668 commit c1bec04

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/ampache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def return_data(self, data):
253253
# json format
254254
if self.AMPACHE_API == 'json':
255255
try:
256-
json_data = json.loads(data.decode('utf-8'))
256+
json_data = data if isinstance(data, dict) else json.loads(data.decode('utf-8'))
257257
except json.decoder.JSONDecodeError:
258258
return False
259259
return json_data
@@ -553,7 +553,7 @@ def handshake(self, ampache_url: str, ampache_api: str, ampache_user=False,
553553
return False
554554
# json format
555555
if self.AMPACHE_API == 'json':
556-
json_data = json.loads(ampache_response.decode('utf-8'))
556+
json_data = ampache_response if isinstance(ampache_response, dict) else json.loads(ampache_response.decode('utf-8'))
557557
if 'api' in json_data:
558558
self.AMPACHE_SERVER = json_data['api']
559559
if 'auth' in json_data:
@@ -603,7 +603,7 @@ def ping(self, ampache_url: str, ampache_api=False, version: str = '6.6.0'):
603603
return False
604604
# json format
605605
if self.AMPACHE_API == 'json':
606-
json_data = json.loads(ampache_response.decode('utf-8'))
606+
json_data = ampache_response if isinstance(ampache_response, dict) else json.loads(ampache_response.decode('utf-8'))
607607
if 'api' in json_data:
608608
self.AMPACHE_SERVER = json_data['api']
609609
if 'session_expire' in json_data:

0 commit comments

Comments
 (0)