Page 1 of 1

Python Shoutcast Client

Posted: 10 Feb 2023 19:18
by jerresnow
I hope this is an easy one. I need to connect to a Shoutcast stream that may or may not be live, but will be live soon. I am using Python with Python-VLC.
If I connect to a live stream, it plays fine with this error

[00000160436e5360] prefetch stream error: unimplemented query (264) in control

I'm not concerned about that as it plays fine. The dead stream responds with this

[000002847da34e10] access stream error: HTTP 401 error
[000002847da2bce0] main input error: Your input can't be opened
[000002847da2bce0] main input error: VLC is unable to open the MRL 'https://sh.fl-us.audio-stream.com/#####/#####'. Check the log for details.

There is no need for authorization, which most of the docs refer to about the HTTP 401 error. I have tried more than a dozen VLC set/get/audio functions to test for a working stream. All my attempts return identical results for the live and the dead stream. What test should I be doing to recognize the lack of audio and retry in 30 seconds for a new attempt?

Re: Python Shoutcast Client

Posted: 10 Feb 2023 20:26
by RĂ©mi Denis-Courmont
HTTP 401 can mean only one thing and that's the server asking for authentication. In other words, it is either a server problem, or an incorrect URL.

Re: Python Shoutcast Client

Posted: 10 Feb 2023 21:12
by jerresnow
It isn't an incorrect URL. Once the feed becomes live, the code works.

Re: Python Shoutcast Client

Posted: 15 Feb 2023 04:19
by jerresnow
Work around: FWIW, I solved this with curl. This script needed to run on Windows, so I didn't try curl till late in the process. Curl gave different responses to the two conditions, live/dead stream. While searching for curl for windows. I was pleasantly surprised to find that curl has been included in Windows for a number of years. Who knew. Anyway, subprocess to get curl's response, and I'm OK.