Merge pull request #387 from jjlawren/plexamp_workaround

Plexamp workaround for bad responses
This commit is contained in:
Steffen Fredriksen 2019-10-11 22:53:11 +02:00 committed by GitHub
commit dbcc796b47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -187,24 +187,27 @@ class PlexClient(PlexObject):
log.debug('Client %s doesnt support %s controller.'
'What your trying might not work' % (self.title, controller))
proxy = self._proxyThroughServer if proxy is None else proxy
query = self._server.query if proxy else self.query
# Workaround for ptp. See https://github.com/pkkid/python-plexapi/issues/244
t = time.time()
if t - self._last_call >= 80 and self.product in ('ptp', 'Plex Media Player'):
url = '/player/timeline/poll?wait=0&commandID=%s' % self._nextCommandId()
if proxy:
self._server.query(url, headers=headers)
else:
self.query(url, headers=headers)
query(url, headers=headers)
self._last_call = t
params['commandID'] = self._nextCommandId()
key = '/player/%s%s' % (command, utils.joinArgs(params))
proxy = self._proxyThroughServer if proxy is None else proxy
if proxy:
return self._server.query(key, headers=headers)
return self.query(key, headers=headers)
try:
return query(key, headers=headers)
except ElementTree.ParseError:
# Workaround for players which don't return valid XML on successful commands
# - Plexamp: `b'OK'`
if self.product in ('Plexamp',):
return
raise
def url(self, key, includeToken=False):
""" Build a URL string with proper token argument. Token will be appended to the URL