From 5fe5109806173625b9d493fe2857ade8d645a4f6 Mon Sep 17 00:00:00 2001 From: Jason Lawrence Date: Tue, 12 May 2020 13:33:20 -0500 Subject: [PATCH 1/2] Remove 'timeline/subscribe' calls --- plexapi/client.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/plexapi/client.py b/plexapi/client.py index e43814969..cf8da602f 100644 --- a/plexapi/client.py +++ b/plexapi/client.py @@ -195,10 +195,11 @@ def sendCommand(self, command, proxy=None, **params): # 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() - query(url, headers=headers) + if command == 'timeline/poll': self._last_call = t + elif t - self._last_call >= 80 and self.product in ('ptp', 'Plex Media Player'): + self._last_call = t + self.timeline() params['commandID'] = self._nextCommandId() key = '/player/%s%s' % (command, utils.joinArgs(params)) @@ -485,15 +486,6 @@ def playMedia(self, media, offset=0, **params): if mediatype == "audio": mediatype = "music" - if self.product != 'OpenPHT': - try: - self.sendCommand('timeline/subscribe', port=server_port, protocol='http') - except: # noqa: E722 - # some clients dont need or like this and raises http 400. - # We want to include the exception in the log, - # but it might still work so we swallow it. - log.exception('%s failed to subscribe ' % self.title) - playqueue = media if isinstance(media, PlayQueue) else self._server.createPlayQueue(media) self.sendCommand('playback/playMedia', **dict({ 'machineIdentifier': self._server.machineIdentifier, @@ -548,7 +540,7 @@ def setStreams(self, audioStreamID=None, subtitleStreamID=None, videoStreamID=No # ------------------- # Timeline Commands - def timeline(self, wait=1): + def timeline(self, wait=0): """ Poll the current timeline and return the XML response. """ return self.sendCommand('timeline/poll', wait=wait) @@ -559,7 +551,7 @@ def isPlayingMedia(self, includePaused=False): includePaused (bool): Set True to treat currently paused items as playing (optional; default True). """ - for mediatype in self.timeline(wait=0): + for mediatype in self.timeline(): if mediatype.get('state') == 'playing': return True if includePaused and mediatype.get('state') == 'paused': From 275f4ba921dadde0395ef1e211a273ab35915a0f Mon Sep 17 00:00:00 2001 From: Jason Lawrence Date: Wed, 13 May 2020 16:36:30 -0500 Subject: [PATCH 2/2] Revert change to default timeline argument --- plexapi/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plexapi/client.py b/plexapi/client.py index cf8da602f..0ec563b23 100644 --- a/plexapi/client.py +++ b/plexapi/client.py @@ -199,7 +199,7 @@ def sendCommand(self, command, proxy=None, **params): self._last_call = t elif t - self._last_call >= 80 and self.product in ('ptp', 'Plex Media Player'): self._last_call = t - self.timeline() + self.timeline(wait=0) params['commandID'] = self._nextCommandId() key = '/player/%s%s' % (command, utils.joinArgs(params)) @@ -540,7 +540,7 @@ def setStreams(self, audioStreamID=None, subtitleStreamID=None, videoStreamID=No # ------------------- # Timeline Commands - def timeline(self, wait=0): + def timeline(self, wait=1): """ Poll the current timeline and return the XML response. """ return self.sendCommand('timeline/poll', wait=wait) @@ -551,7 +551,7 @@ def isPlayingMedia(self, includePaused=False): includePaused (bool): Set True to treat currently paused items as playing (optional; default True). """ - for mediatype in self.timeline(): + for mediatype in self.timeline(wait=0): if mediatype.get('state') == 'playing': return True if includePaused and mediatype.get('state') == 'paused':