Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release 2024-12-11 #2743

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions custom_components/alexa_media/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,12 @@
ATTR_EMAIL = "email"
ATTR_NUM_ENTRIES = "entries"
STREAMING_ERROR_MESSAGE = (
"Sorry folks! Amazon doesn't allow streaming music like this. "
"Please take it up with them!"
"Sorry, direct music streaming isn't supported. "
"This limitation is set by Amazon, and not by Alexa-Media-Player, Music-Assistant, nor Home-Assistant."
)
PUBLIC_URL_ERROR_MESSAGE = (
"To send TTS, please set the public URL in integration configuration."
)
ANNOUNCE_ERROR_MESSAGE = "To send TTS, please set Announce=true."
STARTUP = f"""
-------------------------------------------------------------------
{DOMAIN}
Expand Down
24 changes: 7 additions & 17 deletions custom_components/alexa_media/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
)
from .alexa_media import AlexaMedia
from .const import (
ANNOUNCE_ERROR_MESSAGE,
DEPENDENT_ALEXA_COMPONENTS,
MIN_TIME_BETWEEN_FORCED_SCANS,
MIN_TIME_BETWEEN_SCANS,
Expand Down Expand Up @@ -1378,9 +1377,7 @@ async def async_send_dropin_notification(self, message, **kwargs):
)

@_catch_login_errors
async def async_play_tts_cloud_say(
self, media_type, public_url, media_id, **kwargs
):
async def async_play_tts_cloud_say(self, public_url, media_id, **kwargs):
file_name = media_id
if media_source.is_media_source_id(media_id):
media = await media_source.async_resolve_media(
Expand All @@ -1389,12 +1386,6 @@ async def async_play_tts_cloud_say(
file_name = media.url[media.url.rindex("/") : media.url.rindex(".")]
media_id = async_process_play_media_url(self.hass, media.url)

if media_type == "music":
# Log and notify for Amazon restriction on streaming music
_LOGGER.warning(STREAMING_ERROR_MESSAGE)
await self.async_send_tts(STREAMING_ERROR_MESSAGE)
return

if kwargs.get(ATTR_MEDIA_ANNOUNCE):
input_file_path = self.hass.config.path(
f"{UPLOAD_PATH}{file_name}_input.mp3"
Expand Down Expand Up @@ -1441,8 +1432,8 @@ async def async_play_tts_cloud_say(
f"<audio src='{public_url}local/alexa_tts{output_file_name}' />"
)
else:
await self.async_send_tts(ANNOUNCE_ERROR_MESSAGE)
_LOGGER.warning(ANNOUNCE_ERROR_MESSAGE)
await self.async_send_tts(STREAMING_ERROR_MESSAGE)
_LOGGER.warning(STREAMING_ERROR_MESSAGE)

@_catch_login_errors
async def async_play_media(self, media_type, media_id, enqueue=None, **kwargs):
Expand All @@ -1455,14 +1446,13 @@ async def async_play_media(self, media_type, media_id, enqueue=None, **kwargs):
"options"
].get(CONF_PUBLIC_URL, DEFAULT_PUBLIC_URL)
if media_type == "music":
if not public_url:
if public_url:
# Handle TTS playback
await self.async_play_tts_cloud_say(public_url, media_id, **kwargs)
else:
# Log and notify for missing public URL
_LOGGER.warning(PUBLIC_URL_ERROR_MESSAGE)
await self.async_send_tts(PUBLIC_URL_ERROR_MESSAGE)
else:
# Log and notify for Amazon restriction on streaming music
_LOGGER.warning(STREAMING_ERROR_MESSAGE)
await self.async_send_tts(STREAMING_ERROR_MESSAGE)
elif media_type == "sequence":
_LOGGER.debug(
"%s: %s:Running sequence %s with queue_delay %s",
Expand Down
Loading