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:
jjlawren 2020-05-09 03:59:34 -05:00 committed by GitHub
parent 7da41a6e86
commit e78ceab560
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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}"