Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
Fix/refactor media_error
Browse files Browse the repository at this point in the history
  • Loading branch information
maykar committed Feb 15, 2021
1 parent b14143a commit db8a813
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions custom_components/plex_assistant/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,14 @@ def no_device_error(localize, device=None):

def media_error(command, localize):
error = ""
if command["latest"]:
error += localize["latest"]["keywords"][0] + " "
if command["unwatched"]:
error += localize["unwatched"]["keywords"][0] + " "
if command["ondeck"]:
error += localize["ondeck"]["keywords"][0] + " "
for keyword in ["latest", "unwatched", "ondeck"]:
if command[keyword]:
error += localize[keyword]["keywords"][0] + " "
if command["media"]:
error += "%s " % command["media"].capitalize()
if command["season"]:
error += "%s %s " % (localize["season"]["keywords"][0], command["season"])
if command["episode"]:
error += "%s %s " % (localize["episode"]["keywords"][0], command["episode"])
for keyword in ["season", "episode"]:
if command[keyword]:
error += "%s %s " % (localize[keyword]["keywords"][0], command[keyword])
error += localize["not_found"] + "."
return error.capitalize()

Expand All @@ -141,7 +137,7 @@ def play_tts_error(hass, tts_dir, device, error, lang):
{
"entity_id": device,
"media_content_type": "audio/mp3",
"media_content_id": tts_dir + "error.mp3",
"media_content_id": "/local/plex_assist_tts/error.mp3",
},
)

Expand Down

0 comments on commit db8a813

Please sign in to comment.