Skip to content

Commit

Permalink
some small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Aug 29, 2024
1 parent ccb8d50 commit 3736399
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion music_assistant/server/controllers/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ async def get_media_stream(
if streamdetails.media_type == MediaType.RADIO:
# ffmpeg sometimes has trouble with HLS radio streams stopping
# abruptly for no reason so this is a workaround to keep the stream alive
extra_input_args += ["-stream_loop", "-1"]
extra_input_args += ["-reconnect_at_eof", "1"]
elif streamdetails.stream_type == StreamType.ENCRYPTED_HTTP:
audio_source = streamdetails.path
extra_input_args += ["-decryption_key", streamdetails.decryption_key]
Expand Down
14 changes: 7 additions & 7 deletions music_assistant/server/helpers/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,17 +500,17 @@ async def resolve_radio_stream(mass: MusicAssistant, url: str) -> tuple[str, boo
or "audio/x-scpls" in headers.get("content-type", "")
):
# url is playlist, we need to unfold it
substreams = await fetch_playlist(mass, url)
if not any(x for x in substreams if x.length):
try:
try:
substreams = await fetch_playlist(mass, url)
if not any(x for x in substreams if x.length):
for line in substreams:
if not line.is_url:
continue
# unfold first url of playlist
return await resolve_radio_stream(mass, line.path)
raise InvalidDataError("No content found in playlist")
except IsHLSPlaylist:
is_hls = True
except IsHLSPlaylist:
is_hls = True

except Exception as err:
LOGGER.warning("Error while parsing radio URL %s: %s", url, err)
Expand Down Expand Up @@ -913,9 +913,9 @@ def get_ffmpeg_args(
# these options are only supported in ffmpeg > 5
input_args += [
"-reconnect_on_network_error",
"1",
"5",
"-reconnect_on_http_error",
"5xx",
"5xx,4xx",
]
if input_format.content_type.is_pcm():
input_args += [
Expand Down
4 changes: 3 additions & 1 deletion music_assistant/server/providers/slimproto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,9 @@ def _handle_player_heartbeat(self, slimplayer: SlimClient) -> None:

# elapsed time change on the player will be auto picked up
# by the player manager.
player = self.mass.players.get(slimplayer.player_id)
if not (player := self.mass.players.get(slimplayer.player_id)):
# race condition?!
return
player.elapsed_time = slimplayer.elapsed_seconds
player.elapsed_time_last_updated = time.time()

Expand Down

0 comments on commit 3736399

Please sign in to comment.