Skip to content

Commit

Permalink
enhancement: Raise ProviderUnavailableError in preview if provider is…
Browse files Browse the repository at this point in the history
… unavailable
  • Loading branch information
marcelveldt committed Oct 24, 2024
1 parent abd268b commit 5c70ff2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion music_assistant/server/helpers/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
InvalidDataError,
MediaNotFoundError,
MusicAssistantError,
ProviderUnavailableError,
)
from music_assistant.common.models.media_items import AudioFormat, ContentType
from music_assistant.common.models.streamdetails import StreamDetails
Expand Down Expand Up @@ -739,7 +740,8 @@ async def get_preview_stream(
track_id: str,
) -> AsyncGenerator[bytes, None]:
"""Create a 30 seconds preview audioclip for the given streamdetails."""
music_prov = mass.get_provider(provider_instance_id_or_domain)
if not (music_prov := mass.get_provider(provider_instance_id_or_domain)):
raise ProviderUnavailableError
streamdetails = await music_prov.get_stream_details(track_id)
async for chunk in get_ffmpeg_stream(
audio_input=music_prov.get_audio_stream(streamdetails, 30)
Expand Down

0 comments on commit 5c70ff2

Please sign in to comment.