@@ -187,24 +187,27 @@ def sendCommand(self, command, proxy=None, **params):
187187 log .debug ('Client %s doesnt support %s controller.'
188188 'What your trying might not work' % (self .title , controller ))
189189
190+ proxy = self ._proxyThroughServer if proxy is None else proxy
191+ query = self ._server .query if proxy else self .query
192+
190193 # Workaround for ptp. See https://github.com/pkkid/python-plexapi/issues/244
191194 t = time .time ()
192195 if t - self ._last_call >= 80 and self .product in ('ptp' , 'Plex Media Player' ):
193196 url = '/player/timeline/poll?wait=0&commandID=%s' % self ._nextCommandId ()
194- if proxy :
195- self ._server .query (url , headers = headers )
196- else :
197- self .query (url , headers = headers )
197+ query (url , headers = headers )
198198 self ._last_call = t
199199
200200 params ['commandID' ] = self ._nextCommandId ()
201201 key = '/player/%s%s' % (command , utils .joinArgs (params ))
202202
203- proxy = self ._proxyThroughServer if proxy is None else proxy
204-
205- if proxy :
206- return self ._server .query (key , headers = headers )
207- return self .query (key , headers = headers )
203+ try :
204+ return query (key , headers = headers )
205+ except ElementTree .ParseError :
206+ # Workaround for players which don't return valid XML on successful commands
207+ # - Plexamp: `b'OK'`
208+ if self .product in ('Plexamp' ,):
209+ return
210+ raise
208211
209212 def url (self , key , includeToken = False ):
210213 """ Build a URL string with proper token argument. Token will be appended to the URL
0 commit comments