Fix Plex sensor title handling (#31973)

* Fix Plex sensor title parsing

* Revert episode year for now
This commit is contained in:
jjlawren 2020-02-20 00:33:38 -06:00 committed by GitHub
parent 136ed12ec5
commit 047111b00f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,18 +109,16 @@ class PlexSensor(Entity):
now_playing_user = f"{user} - {device}" now_playing_user = f"{user} - {device}"
now_playing_title = "" now_playing_title = ""
if sess.TYPE == "episode": if sess.TYPE in ["clip", "episode"]:
# example: # example:
# "Supernatural (2005) - S01 · E13 - Route 666" # "Supernatural (2005) - s01e13 - Route 666"
season_title = sess.grandparentTitle season_title = sess.grandparentTitle
if sess.show().year is not None: if sess.show().year is not None:
season_title += " ({0})".format(sess.show().year) season_title += f" ({sess.show().year!s})"
season_episode = "S{0}".format(sess.parentIndex) season_episode = sess.seasonEpisode
if sess.index is not None:
season_episode += f" · E{sess.index}"
episode_title = sess.title episode_title = sess.title
now_playing_title = "{0} - {1} - {2}".format( now_playing_title = (
season_title, season_episode, episode_title f"{season_title} - {season_episode} - {episode_title}"
) )
elif sess.TYPE == "track": elif sess.TYPE == "track":
# example: # example:
@ -128,9 +126,7 @@ class PlexSensor(Entity):
track_artist = sess.grandparentTitle track_artist = sess.grandparentTitle
track_album = sess.parentTitle track_album = sess.parentTitle
track_title = sess.title track_title = sess.title
now_playing_title = "{0} - {1} - {2}".format( now_playing_title = f"{track_artist} - {track_album} - {track_title}"
track_artist, track_album, track_title
)
else: else:
# example: # example:
# "picture_of_last_summer_camp (2015)" # "picture_of_last_summer_camp (2015)"