[SOLVED] Playing radio.net stations from the command line
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
Playing radio.net stations from the command line
There are a number of internet radio stations which can easily be streamed with mplayer. For example this one:
Code:
mplayer http://194.232.200.147:8000 (Radio Salzburg at orf.salzburg.at)
Which is also the recommended way described in various articles. Find out where the stream is coming from, either by viewing the page source or monitoring the network traffic and you are done.
Now there is another type of stations, hosted on the radio.net portal, like http://volksmusikpur.radio.net/ which can impossibly played through the command line.
This particular station can be found on a dozen of websites, and when it is played, the network traffic always shows this:
Regardless of the site where the stream was started from.
Now it is impossible to use any player (mplayer, mpv, vlc) and connect to 164.132.13.80:5070 and get an audio stream.
It seems than in the web browser an script/applet/app is running which makes the connection somehow. It seems that the script or applet does some information exchange before the actual stream is started. The stream is also accessible through an app on Android, which also works.
But not command-line. So the question is, how can I get this stream purely from the command line. Unattended, headless.
Why do I need it command line?
I am in a different time zone than the radio stations I listen to. After a few days it becomes very annoying to listen to the evening/nighttime program in the afternoon. Nighttime programs are not the best.
So I wrote some scripts which record a radio stream, and can play it back with a calculated time offset. It is obvious I have to record the stations of interest 24 hours a day. Starting a web browser on the desktop and recording the audio simply will not do. I have to run a few recording processes (one for each station) in the background as a script.
It works very well with mplayer. But not with the other stations as I described above. Once I have the stream playing from the command line in any way, I know how to record.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Original Poster
Rep:
Thanks for you answer rokytnji.
But I explained in my post I did not have problems with sites I can access with mplayer. Those are fine. Your application uses mpg123 but is otherwise the same. It accesses URL like http://194.232.200.147:8000 and that just plays fine.
In the next part of my post I describe what does not work. http://164.132.13.80:5070 does not work with your application either.
Seems they use their own embbeded player which negates use of command line. Usually I will download .pls file from a radio site which supplies a url for me to use on a command line playlist or command line entry. Or M3U file, or something that I can handle.
Sorry @jlinkels, can't go into a lot of detail in the forum.
Use a webinspector, remote debugging, firebug, python script with something that will run javascript, or just follow all of the references in the api manually.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Original Poster
Rep:
I was afraid of that it really is some interaction between the web site script and the stream server. teckk, thank you for the links. Very nice. As it seems I have to find alternatives.
BUT, I wonder how long it takes before more and more radio stations move to an "app" or a scripted player in the web browser. The "app" or the obligation to run the music from a web browser clearly offers much more options for pushing advertisements. Not that I am against advertisements (the radio sites have to be funded anyway).
And gawdforbid that public or government financed broadcasters move to such player solutions as well. Just now when finally broadcaster seem to have lifted the obligation to run IE or Windows Media Player or Silverlight. Even flash is phased out.
But the "app" is the extension to the human brain. If there is no "app" it doesn't exist what you need.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Original Poster
Rep:
Quote:
Originally Posted by rokytnji
Just wondering. Why not install and run mocp and play downloaded .pls instead? All done without a gui?
I still see a GUI. I think it is ncurses, but it is still a GUI,although not X.
Like I explained in my OP, I want to hear the actual programs with a time shift. So the 6'o clock news at 18:00 local time. That also excludes music from playlists. I want to hear the real program, not playlisted music.
So what I do. I record the program using mplayer. Store it in 1 hour chunks. Run another mplayer which plays back with a time offset. The hard part is BTW to make sure the recording continues and the administration about how to handle gaps in the recordings and stay on time.
To be able to listen any time to a recorded program I have to make sure recording is fully automatic. So that precludes starting a program to select a playlist. It precludes playlists at all because that is not a real program.
I do it, it works, but only for station which can be played with mplayer http://www.example.com
But maybe I am wrong and mocp can play the radio stations unattended when started from the command line. If it plays, I know how to record.
Quote:
Originally Posted by rokytnji
But the title says play by command line.
Alternatives to my favorite stations which can be played only through a browser or the app. Not alternatives for command line.
curl http://167.114.246.177:8127/stream
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
Ok, refuses HEAD requests, ports we want have binary streams on them.
So......
A clunky way of seeing what they have
Code:
for i in {8100..8200}; do
mplayer "http://167.114.246.177:"$i"/stream"
#ffplay "http://167.114.246.177:"$i"/stream"
sleep 1
done
See which ones play.
Or
Code:
agent="Mozilla/5.0 (Windows NT 10.0; WOW64; rv:57.0) Gecko/20100101 Firefox/57.0"
for i in {8100..8105}; do
curl --connect-timeout 2 -A "$agent" http://167.114.246.177:"$i"/stream | head -c 100
#wget -U "$agent" http://167.114.246.177:"$i"/stream -O - | head -c 100
sleep 3
done
See which ports answer with a binary stream
Then put that in a loop
Code:
If curl something....; then
echo "url is a binary stream"
else
echo "url is not a stream"
done
Just wondering. Why not install and run mocp and play downloaded .pls instead? All done without a gui?
Quote:
Originally Posted by jlinkels
I still see a GUI. I think it is ncurses, but it is still a GUI,although not X.
Like I explained in my OP, I want to hear the actual programs with a time shift. So the 6'o clock news at 18:00 local time. That also excludes music from playlists. I want to hear the real program, not playlisted music.
please go to http://pur-radio.com/radioempfang/ , scroll down to "Unser Sender über Externe Player. Dazu einfach auf das Symbol klicken", and download one of the .pls files.
open it in a plain text editor => there's a list of your stream links.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Original Poster
Rep:
Quote:
Originally Posted by ondoho
please go to http://pur-radio.com/radioempfang/ , scroll down to "Unser Sender über Externe Player. Dazu einfach auf das Symbol klicken", and download one of the .pls files.
open it in a plain text editor => there's a list of your stream links.
As easy as that.
Maybe OT, but definitely related. For the life of it, the page you pointed to does not show up for me in Google. What else should I enter in Google but "volksmusic pur" or "volksmusic pur live" "volksmusic pur stream". Even with the keywords on the page you pointed me to "volksmusic pur externe player" does not produce the result. More and more often I get the idea Google plays tricks on me. Which is, showing pages Google thinks which are related to previous searches. But if the previous results were worthless one keeps running in circles, isn't it? So even if I enter 4 keywords from that page it does not show!
@tekk: Good suggestion! However in post #6 you posted exactly this: http://164.132.13.80:5070/stream which is the correct URL. How did you find it then? Your suggestion for cycling through the ports would have worked as well, as long as /stream is attached.
The trick is indeed to postfix the IP: port with /stream
Many thanks guys. Great help! (And apologies to whoever tried to help me and cannot stand the type of music )
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Original Poster
Rep:
Quote:
Originally Posted by jlinkels
That also excludes music from playlists. I want to hear the real program, not playlisted music.
@rokytnji: I was wrong about playlists. The stream IS part of the playlist. Once the .pls is entered in mocp it plays the stream. I really should learn not to jump to premature conclusions.
As you see in the rest of the thread, the trick was to actually find the .pls. And once that was found the contents revealed the stream URL. And could be played with mplayer.
OK, and mocp is useful. At times I am in the same time zone as my radio stations and then I can use mocp to stream music on the Raspi. Instead of carrying a laptop around.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.