Skip to content

Commit

Permalink
Fix: Handle radio stations providing non utf-8 in streamtitle (#1664)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt authored Sep 14, 2024
1 parent ad4a44e commit 605b09f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion music_assistant/server/helpers/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,12 @@ async def get_icy_radio_stream(
stream_title = re.search(rb"StreamTitle='([^']*)';", meta_data)
if not stream_title:
continue
stream_title = stream_title.group(1).decode()
try:
# in 99% of the cases the stream title is utf-8 encoded
stream_title = stream_title.group(1).decode("utf-8")
except UnicodeDecodeError:
# fallback to iso-8859-1
stream_title = stream_title.group(1).decode("iso-8859-1", errors="replace")
cleaned_stream_title = clean_stream_title(stream_title)
if cleaned_stream_title != streamdetails.stream_title:
LOGGER.log(VERBOSE_LOG_LEVEL, "ICY Radio streamtitle original: %s", stream_title)
Expand Down

0 comments on commit 605b09f

Please sign in to comment.