I did the following (in Python):

def get_archive(host, port, sourcename):
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect ((host, port))
        s.sendall(sourcename + '.next\nquit\n')
        data = s.recv(8124).decode('utf-8', 'ignore').encode('utf-8')
        s.close()
        fname=' '.join([l for l in data.split('\n') if 
l.count('[playing]')][0].split(' ')[1:])
        return  re.sub(r"-\d+kbps", "", 
fname.split("/")[-1].replace("unknown-","").replace(".ogg","").replace(".mp3",""))
    except:
        pass


If you call it get_archive("localhost", 1234, "sourcename") it'll return the 
track playing only if it is playing.

If you have only one playlist, use that for sourcename. Otherwise, you could 
loop through all the sources, and check them individually; only the ones that 
are playing will return non-Null.

-ken
--
------
On Tue, Oct 20, 2015 at 07:33:52PM -0400, Nicholas Vrtis wrote:
> Using Verion 1.0.1
> 
> How do I tell if a source is actually playing?
> 
> I have a LiquidSoap script where I have created a couple of new Telnet
> server commands.
> 
> Amoung other information, I would like to return whether a source is
> currently playing.
> 
> There is a Telnet Server command <source>.status which will tell me if the
> source is started or stopped.
> 
> I would like to be able to include the code to determine the same
> information in my LIquidSoap code.
> 
> 
> Thanks.  Nick

> ------------------------------------------------------------------------------

> _______________________________________________
> Savonet-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/savonet-users


------------------------------------------------------------------------------
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to