another radio script (updated to v2)

Submitted scripts and programs
Forum rules
Your own work only.
pidsley
Hermit
Posts: 2539
Joined: Wed Oct 17, 2012 12:31 pm

another radio script (updated to v2)

Unread post by pidsley » Mon Mar 10, 2014 11:18 pm

We have raffles, and we have bbqradio. Why do we need another radio script? We don't, but I wrote one anyway.

I call this "tinyradio" -- at seven lines of code, it's a tiny internet radio player. It reads a list of streams from ~/.config/tinyradio/stream-list, and uses mpg123 to play the stream you select. I included all the available streams from somafm, but you can delete some or add more if you like, and it should even work with .pls files from other players.

The script:

Code: Select all

#!/bin/bash

STREAM_FILE=~/.config/tinyradio/stream-list

[[ ! -f "$STREAM_FILE" ]] && echo "$STREAM_FILE does not exist" && exit 1

array=( $(cat "$STREAM_FILE") )

select opt in "${array[@]}"; do
    mpg123 -@ "$opt"
    break
done
Here is the stream file (put this in ~/.config/tinyradio/stream-list, or change the search path in the script). Add or remove streams, and the script should build the appropriate list:

Code: Select all

http://somafm.com/groovesalad.pls
http://somafm.com/lush.pls
http://somafm.com/earwaves.pls
http://somafm.com/deepspaceone.pls
http://somafm.com/spacestation.pls
http://somafm.com/missioncontrol.pls
http://somafm.com/dronezone.pls
http://somafm.com/poptron.pls
http://somafm.com/events.pls
http://somafm.com/dubstep.pls
http://somafm.com/indiepop.pls
http://somafm.com/folkfwd.pls
http://somafm.com/bagel.pls
http://somafm.com/digitalis.pls
http://somafm.com/sonicuniverse.pls
http://somafm.com/secretagent.pls
http://somafm.com/illstreet.pls
http://somafm.com/thetrip.pls
http://somafm.com/cliqhop.pls
http://somafm.com/covers.pls
http://somafm.com/u80s.pls
http://somafm.com/beatblender.pls
http://somafm.com/doomed.pls
Run the tinyradio script, choose the stream you want to play, and enjoy.

If you are too lazy to add this yourself, I plan to include it in my next spin.

User avatar
ChefIronBelly
Approved BBQer
Posts: 1044
Joined: Mon Jan 13, 2014 6:01 am
Location: Michigan

Re: another radio script

Unread post by ChefIronBelly » Mon Mar 10, 2014 11:43 pm

added working sweet.
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]

User avatar
DebianJoe
Frame Buffer
Posts: 1915
Joined: Mon Jul 01, 2013 5:41 am
Location: emacs.d

Re: another radio script

Unread post by DebianJoe » Tue Mar 11, 2014 12:31 am

Very good work Pidsley!
|>>BBQ Roaster, Alpha Branch<< | >> clinky << | >> X11 must die << |
Thanks BASIC

User avatar
bones
Clooney
Posts: 2385
Joined: Fri Jun 28, 2013 11:47 pm
Location: Cascadia

Re: another radio script

Unread post by bones » Tue Mar 11, 2014 2:08 am

Works great, currently listening to Defcon Radio (#9). Thanks, pidsley!

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: another radio script

Unread post by rhowaldt » Tue Mar 11, 2014 9:22 am

cool shit, tiny indeed! well done :)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: another radio script

Unread post by GekkoP » Tue Mar 11, 2014 10:35 am

oh yes, added here too. Thanks for this one.

User avatar
ivanovnegro
Minister of Truth
Posts: 5448
Joined: Wed Oct 17, 2012 11:12 pm

Re: another radio script

Unread post by ivanovnegro » Tue Mar 11, 2014 3:42 pm

Thanks for this Pid. Added to my script collection.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: another radio script

Unread post by GekkoP » Wed Mar 12, 2014 10:50 am

Loving it. And I have to say thanks again because I wasn't used to somafm and in those streams there is the kind of music that perfectly suits my taste.

pidsley
Hermit
Posts: 2539
Joined: Wed Oct 17, 2012 12:31 pm

Re: another radio script

Unread post by pidsley » Fri Mar 14, 2014 8:20 pm

Here is tinyradio v2. This one adds one line, plus a "-r" argument and streamripper -- use "tinyradio -r" to call streamripper to rip the stream to mp3 while you are listening to it. Read "man streamripper" to see how to specify the directory where streamripper puts the ripped music. Note that streamripper will tell you it is skipping the first song you listen to; once it can rip a complete song it will start.

Code: Select all

#!/bin/bash

STREAM_FILE=~/.config/tinyradio/stream-list

[[ ! -f "$STREAM_FILE" ]] && echo "$STREAM_FILE does not exist" && exit 1

array=( $(cat "$STREAM_FILE") )

select opt in "${array[@]}"; do
    [[ $1 =~ ^-r ]] && streamripper "$opt" &
    mpg123 -@ "$opt"
    break
done
https://github.com/pidsley/codemangler/ ... /tinyradio

I also should have apologized to machinebacon for not mentioning his "easy peasy radio script" much earlier. (Honestly, I forgot about it.) All the streams from that script should also work with tinyradio, and streamripper should work with his script as well. The only real difference is that tinyradio doesn't use dialog.

User avatar
ivanovnegro
Minister of Truth
Posts: 5448
Joined: Wed Oct 17, 2012 11:12 pm

Re: another radio script (updated to v2)

Unread post by ivanovnegro » Fri Mar 14, 2014 9:17 pm

I use both. :) Now I really prefer yours Pidsley, maybe I find dialog just a bit annoying.
Don't kill me Bacon. :)

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: another radio script (updated to v2)

Unread post by wuxmedia » Fri Mar 14, 2014 9:39 pm

I must be really boring, I just have 2 radio channels I listen to aliased 8)
thanks for sharing.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
ChefIronBelly
Approved BBQer
Posts: 1044
Joined: Mon Jan 13, 2014 6:01 am
Location: Michigan

Re: another radio script (updated to v2)

Unread post by ChefIronBelly » Sat Mar 15, 2014 1:56 am

Updated :)
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: another radio script (updated to v2)

Unread post by dkeg » Sat Mar 15, 2014 2:04 am

Just now doing some catching up. Great contribution pids. Thank you.

Work hard; Complain less

pidsley
Hermit
Posts: 2539
Joined: Wed Oct 17, 2012 12:31 pm

Re: another radio script (updated to v2)

Unread post by pidsley » Sat Mar 15, 2014 2:34 am

wuxmedia wrote:I must be really boring, I just have 2 radio channels I listen to aliased 8)
thanks for sharing.
NP wux -- I have one alias for listening, and one for ripping, both the same stream. Too many choices just confuses me. ;)

User avatar
brontosaurusrex
Distrowatcher
Posts: 2
Joined: Mon Jul 22, 2013 5:27 pm

Re: another radio script (updated to v2)

Unread post by brontosaurusrex » Fri May 02, 2014 1:04 pm

Love the script, thanks for sharing.
p.s. I'd add a small buffer to mpg123 line like -b 2000

edit: a mpv edition, since mpv supports more audio formats;

Code: Select all

#!/bin/bash

STREAM_FILE=~/bin/radiolist

[[ ! -f "$STREAM_FILE" ]] && echo "$STREAM_FILE does not exist" && exit 1

array=( $(cat "$STREAM_FILE") )

select opt in "${array[@]}"; do
    [[ $1 =~ ^-r ]] && streamripper "$opt" &
    # mpg123 -b 2000 -@ "$opt"
    mpv --load-unsafe-playlists "$opt" --cache 1000 --msglevel=cplayer=no:ffmpeg/audio=no:ffmpeg/demuxer=no:ffmpeg/video=no:ad=no --no-video
    break
done
Last edited by brontosaurusrex on Mon May 12, 2014 8:34 pm, edited 1 time in total.

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: another radio script (updated to v2)

Unread post by wuxmedia » Fri May 02, 2014 6:18 pm

^ depends on the stream, some of them really do need a 2048k buffer, others play all day without anything.
Still, BBQ philosophy asks you to season as you need. 8)
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
Alad
should take a shower
Posts: 447
Joined: Wed May 21, 2014 12:52 am

Re: another radio script (updated to v2)

Unread post by Alad » Wed Jun 04, 2014 9:06 pm

brontosaurusrex wrote:edit: a mpv edition, since mpv supports more audio formats.
Great fan of mpv, cheers for the script (and now I finally know why some streams stop randomly!)
It's funny how we used to be able to do real stuff with rudimentary computers, but now we can't. -- ratcheer

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: another radio script (updated to v2)

Unread post by GekkoP » Thu Jul 24, 2014 10:26 am

Still using and liking this script, so thanks Pidsley for taking the time to share it. Just one thing, if anyone is interested. I changed this line:

Code: Select all

mpg123 -@ "$opt"
to this:

Code: Select all

mpg123 -C -@ "$opt"
This one adds some control using keybindings: 'q' for quit, 's' for stop/start, etc. Just have a look at mpg123 man page for more info.

User avatar
ivanovnegro
Minister of Truth
Posts: 5448
Joined: Wed Oct 17, 2012 11:12 pm

Re: another radio script (updated to v2)

Unread post by ivanovnegro » Thu Jul 24, 2014 3:59 pm

^ Nice addition Gekko.

pidsley
Hermit
Posts: 2539
Joined: Wed Oct 17, 2012 12:31 pm

Re: another radio script (updated to v2)

Unread post by pidsley » Sun Sep 20, 2015 5:21 pm

Added some code to run without a stream file. On my github here: https://github.com/pidsley/codemangler/ ... /tinyradio

Post Reply