Skip to content

Commit 8f329f5

Browse files
committed
Simplify query calls, fix proxy bug
1 parent 23a5ad6 commit 8f329f5

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

plexapi/client.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,31 +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-
205203
try:
206-
if proxy:
207-
return self._server.query(key, headers=headers)
208-
return self.query(key, headers=headers)
204+
return query(key, headers=headers)
209205
except ElementTree.ParseError:
210206
# Workaround for players which don't return valid XML on successful commands
211207
# - Plexamp: `b'OK'`
212-
if self.product not in ('Plexamp'):
213-
raise
214-
208+
if self.product in ('Plexamp'):
209+
return None
210+
raise
215211

216212
def url(self, key, includeToken=False):
217213
""" Build a URL string with proper token argument. Token will be appended to the URL

0 commit comments

Comments
 (0)