LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 02-25-2018, 08:10 AM   #1
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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:
Code:
hope.streampanel.cloud <-> donald-pc.megaline.com 
164.132.13.80 5070    TCP     192.168.110.130  48287
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.

jlinkels

Last edited by jlinkels; 02-25-2018 at 08:16 AM.
 
Old 02-25-2018, 10:47 AM   #2
rokytnji
LQ Veteran
 
Registered: Mar 2008
Location: Waaaaay out West Texas
Distribution: antiX 23, MX 23
Posts: 7,112
Blog Entries: 21

Rep: Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474
Well, you are welcome to use what I use.

https://github.com/hakerdefo/pmrp

What I used before the above < my radio station lists need updating >

https://pastebin.com/JNp1eTfp

mplayer is required for the above script.

As far as recording. I can't help with that.

Forgot to mention. If putting my script in /home/username.

I run it like so

./cl>what ever you name it.

Also forgot to mention for anyone reading this thread. My file permissions.

Code:
$ ls -l cl1
-rwxrwxrwx 1 harry harry 3655 Nov  5 16:47 cl1
harry shows username in /home. Yours will be different.

Last edited by rokytnji; 02-25-2018 at 11:07 AM.
 
Old 02-25-2018, 04:01 PM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Original Poster
Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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.

jlinkels
 
Old 02-26-2018, 09:18 AM   #4
rokytnji
LQ Veteran
 
Registered: Mar 2008
Location: Waaaaay out West Texas
Distribution: antiX 23, MX 23
Posts: 7,112
Blog Entries: 21

Rep: Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474
Sorry then. BEING more of a Help Desk on this forum instead of tech dept. I probably over stepped my skill set.

I went to the link http://pur-radio.com/ which comes from http://164.132.13.80:5070/

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.

Last edited by rokytnji; 02-26-2018 at 09:20 AM.
 
Old 02-26-2018, 09:28 AM   #5
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
A quick look at their code tells they use javascript to interact with player. Phooey.
 
Old 02-27-2018, 08:12 AM   #6
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Code:
wget --spider http://164.132.13.80:5070
Connecting to 164.132.13.80:5070... connected.
HTTP request sent, awaiting response... 400 Bad Request
Remote file does not exist -- broken link!!!
Quote:
So the question is, how can I get this stream purely from the command line.
Looked at the url:

http://volksmusikpur.radio.net/trans...5ab2e3&lang=us

https://api.radio.net/info/v2/user/a...7c16e5375ab2e3

https://api.radio.net/info/v2/search...1,35794,106357

http://volksmusikpur.radio.net/trans...5ab2e3&lang=us

The url is:
Code:
mplayer http://164.132.13.80:5070/stream
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.

Here are a few more
http://167.114.246.177:8127/stream
http://167.114.246.177:8139/stream
http://167.114.246.177:8123/stream

Und Ich hoere Volksmusik. Alles tanzen Mussen!
 
1 members found this post helpful.
Old 02-27-2018, 09:56 AM   #7
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Original Poster
Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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.

jlinkels
 
Old 02-27-2018, 10:06 AM   #8
rokytnji
LQ Veteran
 
Registered: Mar 2008
Location: Waaaaay out West Texas
Distribution: antiX 23, MX 23
Posts: 7,112
Blog Entries: 21

Rep: Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474
Just wondering. Why not install and run mocp and play downloaded .pls instead? All done without a gui?

I keep my stuff simple and stupid. It is still command line. Trying not to be off topic.

Quote:
As it seems I have to find alternatives.
But the title says play by command line.

Screenshot

Last edited by rokytnji; 02-27-2018 at 10:10 AM.
 
1 members found this post helpful.
Old 02-27-2018, 11:24 AM   #9
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Original Poster
Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by rokytnji View Post
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 View Post
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.

jlinkels

Last edited by jlinkels; 02-27-2018 at 11:26 AM.
 
Old 02-27-2018, 12:00 PM   #10
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Just a few thoughts. A little bit of bash and friends would be useful here.

Now that you have some general info on what they are doing.(See post 6) same ip, different ports

Code:
curl -LI http://167.114.246.177:8127/stream
HTTP/1.0 400 Bad Request
Server: Icecast 2.4.2
Date: Tue, 27 Feb 2018 16:47:19 GMT
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Pragma: no-cache
Code:
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
 
1 members found this post helpful.
Old 02-27-2018, 12:45 PM   #11
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by rokytnji View Post
Just wondering. Why not install and run mocp and play downloaded .pls instead? All done without a gui?
Quote:
Originally Posted by jlinkels View Post
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.
 
1 members found this post helpful.
Old 02-27-2018, 03:52 PM   #12
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Original Poster
Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by ondoho View Post
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 )

jlinkels

Last edited by jlinkels; 02-27-2018 at 04:06 PM.
 
Old 02-27-2018, 05:07 PM   #13
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Original Poster
Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by jlinkels View Post
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.

jlinkels
 
Old 02-27-2018, 08:20 PM   #14
rokytnji
LQ Veteran
 
Registered: Mar 2008
Location: Waaaaay out West Texas
Distribution: antiX 23, MX 23
Posts: 7,112
Blog Entries: 21

Rep: Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474
Thanks for the rep and yeah. You must be in a bad spot of the universe. Because ondohos link takes me to

https://cdn.scrot.moe/images/2018/02/28/screenshot1.jpg

Maybe use duck duck go or startpage instead? I even have also been known to use dogpile search.

When I don't feel like using google.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Exaile - Can't play radio stations Irajas Linux - Software 0 05-06-2007 03:24 PM
online radio stations radiodee1 Linux - Newbie 4 03-24-2007 04:52 PM
Online radio stations Shadzilla Linux - Software 10 03-04-2005 08:31 AM
Multiple LAN-radio-stations greggy69 Linux - Software 0 06-23-2004 05:43 AM
AM/FM Radio Stations Aljaber Linux - General 5 11-11-2003 12:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration