music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.39k stars 51 forks source link

Incorrect parsing in radio URL #2637

Closed tgozed closed 4 months ago

tgozed commented 4 months ago

What version of Music Assistant has the issue?

2.0.7

What version of the Home Assistant Integration have you got installed?

None yet, I'm trying to play directly through music assistant

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

The problem

I'm trying to add a custom radio station URL that's subscription based and therefore each users URL is personal.

An obfuscated URL for the stream is: https://stream.primordialradio.com/proxy/primordial?mp=/stream%3Fname=

However when looking at the logs, music assistant is parsing the %3F in the URL as a ? - unfortunately this leads to a 401 unauthenticated error.

I can verify this in chrome, where I can play the stream with %3F present, but when using ? instead, chrome also returns a 401 error.

2024-07-16 13:35:51.426 WARNING (MainThread) [music_assistant.audio] Error while parsing radio URL https://stream.primordialradio.com/proxy/primordial?mp=/stream%3Fname=: 401, message='Authentication Required', url=URL('https://stream.primordialradio.com/proxy/primordial?mp=/stream?name=')

How to reproduce

Unfortunately you will not be able to directly reproduce this error without my authenticated URL which I'm not able to provide publicly. You will not be able to enter a dummy URL as it will return the 401 immediately and not allow you to add the URL to music assistant.

I can add my URL to music assistant fine, it's only when attempting to play it that it parses it wrong.

Music Providers

Inputted the URL directly into music assistant as a radio station.

Player Providers

SONOS

Full log output

I believe the single line above shows the problem.

Additional information

No response

What version of Home Assistant Core are your running

2024.7.2

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Generic x86-64 (e.g. Intel NUC)

MelHarbour commented 4 months ago

I think this is an example of this happening: https://github.com/aio-libs/aiohttp/issues/1725

It might work to do as they say and add encoded=True to the code, but I'm a little cautious about what the desired behaviour is. Need to check with @marcelveldt

marcelveldt commented 4 months ago

should be fixed in next release

OzGav commented 4 months ago

@tgozed You need to try the beta 2.1.0rc3 to see this fix

tgozed commented 4 months ago

Very happy to confirm this issue is now fixed in 2.1.0rc3. Thank you so much!