From: Marcel van der Veldt Date: Sat, 14 Sep 2024 23:55:38 +0000 (+0200) Subject: Fix: Handle radio stations providing non utf-8 in streamtitle (#1664) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=605b09fa381827b9d6a348237a7b7d0e5e9dadeb;p=music-assistant-server.git Fix: Handle radio stations providing non utf-8 in streamtitle (#1664) --- diff --git a/music_assistant/server/helpers/audio.py b/music_assistant/server/helpers/audio.py index 84f08add..6c975b1f 100644 --- a/music_assistant/server/helpers/audio.py +++ b/music_assistant/server/helpers/audio.py @@ -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)