extract stream title from the output of mplayer

Jabba Laci jabba.laci at gmail.com
Tue Mar 18 13:03:26 EDT 2014


Hi,

I have a simple command-line radio player and I want to extract song
titles from the output of mplayer.

Example:

$ mplayer http://relay2.slayradio.org:8000/

It produces a streamed output of this form:

MPlayer2 UNKNOWN (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
...
ICY Info: StreamTitle='Alexander 'Taxim' Nev - Unsound minds feat.
SAM';StreamUrl='http://www.SLAYRadio.org/';
...

At the end it shows a progress indicator, thus the output is streamed.
The problem is I can't get this output in a string. My idea is to
launch mplayer with a timeout of 2 seconds for instance, get the
produced output and find the line that starts with "ICY Info". But
when I kill the process after the timeout, I don't know how to fetch
the output produced so far.

Thanks,

Laszlo



More information about the Python-list mailing list