Fix Plex from doing I/O inside event loop (#4857)
This commit is contained in:
parent
2402897f47
commit
1e9d91be0e
1 changed files with 8 additions and 3 deletions
|
@ -200,6 +200,7 @@ class PlexClient(MediaPlayerDevice):
|
||||||
self.update_devices = update_devices
|
self.update_devices = update_devices
|
||||||
self.update_sessions = update_sessions
|
self.update_sessions = update_sessions
|
||||||
self.set_device(device)
|
self.set_device(device)
|
||||||
|
self._season = None
|
||||||
|
|
||||||
def set_device(self, device):
|
def set_device(self, device):
|
||||||
"""Set the device property."""
|
"""Set the device property."""
|
||||||
|
@ -240,9 +241,15 @@ class PlexClient(MediaPlayerDevice):
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest details."""
|
"""Get the latest details."""
|
||||||
|
from plexapi.video import Show
|
||||||
|
|
||||||
self.update_devices(no_throttle=True)
|
self.update_devices(no_throttle=True)
|
||||||
self.update_sessions(no_throttle=True)
|
self.update_sessions(no_throttle=True)
|
||||||
|
|
||||||
|
if isinstance(self.session, Show):
|
||||||
|
self._season = self._convert_na_to_none(
|
||||||
|
self.session.seasons()[0].index)
|
||||||
|
|
||||||
# pylint: disable=no-self-use, singleton-comparison
|
# pylint: disable=no-self-use, singleton-comparison
|
||||||
def _convert_na_to_none(self, value):
|
def _convert_na_to_none(self, value):
|
||||||
"""Convert PlexAPI _NA() instances to None."""
|
"""Convert PlexAPI _NA() instances to None."""
|
||||||
|
@ -310,9 +317,7 @@ class PlexClient(MediaPlayerDevice):
|
||||||
@property
|
@property
|
||||||
def media_season(self):
|
def media_season(self):
|
||||||
"""Season of curent playing media (TV Show only)."""
|
"""Season of curent playing media (TV Show only)."""
|
||||||
from plexapi.video import Show
|
return self._season
|
||||||
if isinstance(self.session, Show):
|
|
||||||
return self._convert_na_to_none(self.session.seasons()[0].index)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_series_title(self):
|
def media_series_title(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue