Skip to content

Commit 787100e

Browse files
committed
Update ampache.py
1 parent 29b544a commit 787100e

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
@@ -260,7 +260,7 @@ def return_data(self, data):
260260
# xml format
261261
else:
262262
try:
263-
tree = ElementTree.fromstring(data.decode('utf-8'))
263+
tree = data if isinstance(data, ElementTree.Element) else ElementTree.fromstring(data.decode('utf-8') if isinstance(data, bytes) else data)
264264
except ElementTree.ParseError:
265265
return False
266266
return tree
@@ -565,7 +565,7 @@ def handshake(self, ampache_url: str, ampache_api: str, ampache_user=False,
565565
# xml format
566566
else:
567567
try:
568-
tree = ElementTree.fromstring(ampache_response.decode('utf-8'))
568+
tree = ampache_response if isinstance(ampache_response, ElementTree.Element) else ElementTree.fromstring(ampache_response.decode('utf-8') if isinstance(ampache_response, bytes) else ampache_response)
569569
except ElementTree.ParseError:
570570
return False
571571
try:
@@ -617,7 +617,7 @@ def ping(self, ampache_url: str, ampache_api=False, version: str = '6.6.0'):
617617
# xml format
618618
else:
619619
try:
620-
tree = ElementTree.fromstring(ampache_response.decode('utf-8'))
620+
tree = ampache_response if isinstance(ampache_response, ElementTree.Element) else ElementTree.fromstring(ampache_response.decode('utf-8') if isinstance(ampache_response, bytes) else ampache_response)
621621
except ElementTree.ParseError:
622622
return False
623623
try:

0 commit comments

Comments
 (0)