-
-
Save bonelifer/a56991e77a52ab9f5467fede65f9bb42 to your computer and use it in GitHub Desktop.
SomaFM from the command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# description: Update somafm stations in the stations.sh file | |
# original: https://github.com/rockymadden/somafm-cli/ | |
# deleted all non channel retrieval functionality and | |
# made it output the format expected by stations.sh | |
# and use sed to make the channel update to stations.sh | |
# Fetch channel names and format them for stations array | |
channels=$(curl -s -H 'Accept: application/json' https://somafm.com/channels.json | \ | |
jq -r '.channels | map(.id | @sh) | join(" ")') | |
# Update stations.sh content | |
content="declare -a stations=($channels)" | |
# Update stations.sh file | |
sed -i "s|^declare -a stations=.*|$content|" stations.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# description: Use mplayer to play somafm stations from commandline. | |
# If no station name it will print out the available stations. | |
# original: https://gist.github.com/tomrod/0b5caceec1a10acfb134aefb5fd85b93 | |
# changed it from a function that would be put into .bashrc to a standalone script | |
# also added getsomastations.sh which grabs the current list of stations and edits | |
# this file. | |
# Declare stations array outside the function | |
declare -a stations=('7soul' 'beatblender' 'bootliquor' 'brfm' 'christmas' 'cliqhop' 'covers' 'deepspaceone' 'defcon' 'digitalis' 'doomed' 'dronezone' 'dubstep' 'fluid' 'folkfwd' 'groovesalad' 'gsclassic' 'illstreet' 'indiepop' 'jollysoul' 'live' 'lush' 'missioncontrol' 'poptron' 'secretagent' 'seventies' 'sf1033' 'sonicuniverse' 'spacestation' 'suburbsofgoa' 'thetrip' 'thistle' 'u80s' 'xmasinfrisko' 'xmasrocks' 'metal' 'reggae' 'scanner' 'vaporwaves' 'specials' 'n5md' 'synphaera' 'darkzone' 'sfinsf' 'tikitime' 'bossa' 'insound' 'deptstore') | |
function listen_soma() { | |
local playlist=$1 | |
local found=false | |
for station in "${stations[@]}"; do | |
if [ "$playlist" == "$station" ]; then | |
found=true | |
break | |
fi | |
done | |
if [ "$found" = true ]; then | |
mplayer -really-quiet -playlist "http://soma.fm/${playlist}.pls" 2>/dev/null | |
else | |
echo "Station not in station list: $playlist" | |
echo "Available stations:" | |
printf '%s\n' "${stations[@]}" | column -c 80 -x | |
echo "Please provide a station name as an argument." | |
fi | |
} | |
# Check if an argument was provided | |
if [ "$#" -eq 1 ]; then | |
listen_soma "$1" | |
else | |
echo "Available stations:" | |
printf '%s\n' "${stations[@]}" | column -c 80 -x | |
echo "Please provide a station name as an argument." | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment