extract stream title from the output of mplayer

Chris Angelico rosuav at gmail.com
Tue Mar 18 18:12:43 CET 2014


On Wed, Mar 19, 2014 at 4:03 AM, Jabba Laci <jabba.laci at gmail.com> wrote:
> I have a simple command-line radio player and I want to extract song
> titles from the output of mplayer.
>
> 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.

My first recommendation would be to see what you can get directly,
rather than calling on mplayer. But otherwise, what you want to do is
redirect the output somewhere. Are you using the Python subprocess
module to do this? You haven't shown any code, but since you posted
this to python-list I'm guessing that you probably are talking about
Python. (Or s/guess/hop/ if you prefer!) There are many ways this
could be done; what have you tried, what partly worked, what did
something unexpected?

ChrisA



More information about the Python-list mailing list