Skip to content

Instantly share code, notes, and snippets.

@7h3rAm
Last active January 8, 2024 00:37
Show Gist options
  • Save 7h3rAm/0669452c1380e52e23764dedfb733797 to your computer and use it in GitHub Desktop.
Save 7h3rAm/0669452c1380e52e23764dedfb733797 to your computer and use it in GitHub Desktop.
SomaFM Radio (somafm+bat+fzf+mpv)
#!/usr/bin/env bash
[[ $# -ge 1 ]] && radio="mpv --volume=$1 --cache=yes --demuxer-max-bytes=2000000000" || radio="mpv --volume=80 --cache=yes --demuxer-max-bytes=2000000000"
echo 'genre,title,id,listeners,description' >/tmp/somafm
curl -s -H "Accept: application/json" "https://somafm.com/channels.json" | \
jq -r '.channels[]|["(\(.genre)),\(.title),\(.id),\(.listeners) listeners,\(.description)"]|@csv' | \
tr -d '"' | \
sort >>/tmp/somafm
channel=$(bat -l csv --color=always -p /tmp/somafm | \
fzf -i \
--exact \
--cycle \
--no-multi \
--no-sort \
--layout=reverse \
--info=inline \
--pointer='>' \
--marker='*' \
--header-lines=1 \
--border-label=$'🎧 SomaFM Player ' \
--border-label-pos=3 \
--prompt=' search: ' \
--preview-window='' \
--preview='' | \
cut -d"," -f3)
[[ ! -z "$channel" ]] && $radio "http://somafm.com/${channel}.pls"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment