Skip to content

Commit 6ef1e9c

Browse files
committed
Check in sendCommand instead of query
1 parent 6f789e3 commit 6ef1e9c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

plexapi/client.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ def query(self, path, method=None, headers=None, timeout=None, **kwargs):
165165
log.warning('BadRequest (%s) %s %s; %s' % (response.status_code, codename, response.url, errtext))
166166
raise BadRequest('(%s) %s; %s %s' % (response.status_code, codename, response.url, errtext))
167167
data = response.text.encode('utf8')
168-
if data == b'OK': # Workaround for misbehaving clients such as Plexamp
169-
data = ''
170168
return ElementTree.fromstring(data) if data.strip() else None
171169

172170
def sendCommand(self, command, proxy=None, **params):
@@ -204,6 +202,16 @@ def sendCommand(self, command, proxy=None, **params):
204202

205203
proxy = self._proxyThroughServer if proxy is None else proxy
206204

205+
if self.product in ('Plexamp'):
206+
# Workaround for players which don't return valid XML on successful commands
207+
# - Plexamp: `b'OK'`
208+
try:
209+
if proxy:
210+
return self._server.query(key, headers=headers)
211+
return self.query(key, headers=headers)
212+
except ElementTree.ParseError:
213+
return None
214+
207215
if proxy:
208216
return self._server.query(key, headers=headers)
209217
return self.query(key, headers=headers)

0 commit comments

Comments
 (0)