Wrap Plex property that can make I/O requests (#35383)
* Wrap property that sometimes makes I/O requests * Simpler solution * Combine into single function
This commit is contained in:
parent
7da41a6e86
commit
e78ceab560
1 changed files with 7 additions and 2 deletions
|
@ -85,11 +85,16 @@ class PlexSensor(Entity):
|
|||
if sess.TYPE in ["clip", "episode"]:
|
||||
# example:
|
||||
# "Supernatural (2005) - s01e13 - Route 666"
|
||||
|
||||
def sync_io_attributes(session):
|
||||
return (session.show(), session.seasonEpisode)
|
||||
|
||||
show, season_episode = await self.hass.async_add_executor_job(
|
||||
sync_io_attributes, sess
|
||||
)
|
||||
season_title = sess.grandparentTitle
|
||||
show = await self.hass.async_add_executor_job(sess.show)
|
||||
if show.year is not None:
|
||||
season_title += f" ({show.year!s})"
|
||||
season_episode = sess.seasonEpisode
|
||||
episode_title = sess.title
|
||||
now_playing_title = (
|
||||
f"{season_title} - {season_episode} - {episode_title}"
|
||||
|
|
Loading…
Add table
Reference in a new issue