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]
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)
# 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 += [
# 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()