Skip to content

Instantly share code, notes, and snippets.

@flxai
Created October 2, 2021 11:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flxai/2876eed80476f5fea9a1783b6c13cf83 to your computer and use it in GitHub Desktop.
Save flxai/2876eed80476f5fea9a1783b6c13cf83 to your computer and use it in GitHub Desktop.
SomaFM client in bash using mpv and pup

SomaFM in bash

Install pup and mpv, place somewhere and execute. It gives a menu like the following that allows you to select the station:

Getting radio stations...
-#O=#   #   #
 1) doomed           12) gsclassic        23) 7soul           34) missioncontrol
 2) dronezone        13) synphaera        24) seventies       35) sf1033
 3) deepspaceone     14) n5md             25) u80s            36) scanner
 4) spacestation     15) beatblender      26) reggae          37) sfinsf
 5) vaporwaves       16) bootliquor       27) secretagent     38) bagel
 6) defcon           17) illstreet        28) thetrip         39) live
 7) lush             18) thistle          29) sonicuniverse   40) xmasinfrisko
 8) fluid            19) metal            30) indiepop        41) christmas
 9) poptron          20) covers           31) digitalis       42) xmasrocks
10) suburbsofgoa     21) cliqhop          32) folkfwd         43) jollysoul
11) groovesalad      22) dubstep          33) brfm                
#?

You can quit mpv using either q or Ctrl + C to select another channel.

Support

If you like this script please support SomaFM – ideally with a monthly subscription.

#!/usr/bin/env bash
# Get SomaFM radio stations and streams them using mpv
base_url="https://somafm.com"
echo "Getting radio stations..."
stations=$(curl -# "$base_url" | pup .cbshort a attr{href} | sed -re 's_/([a-z0-9]+)/_\1_')
while :; do
select station in $stations; do
echo "Streaming $station..."
mpv --no-video "$base_url/$station.pls"
break
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment