Skip to content

Instantly share code, notes, and snippets.

@SydLambert
Created May 2, 2020 18:59
Show Gist options
  • Save SydLambert/e15622c7ef9f30ee27b02a29172bcfbc to your computer and use it in GitHub Desktop.
Save SydLambert/e15622c7ef9f30ee27b02a29172bcfbc to your computer and use it in GitHub Desktop.
Add all channels on Soma FM to MPD as individual playlists. Requires mpc and GNU grep. Will empty playlist before starting.
#!/usr/bin/env sh
mpc clear
curl -s https://somafm.com/channels.xml | grep -Po '((?<=<title><!\[CDATA\[).+?(?=\])|(?<=id=").+?(?="))' | sed 'N;s/\n/ /' | while read -r p; do
curl -s "https://somafm.com/$(echo "$p" | grep -Po '^.+?(?= )')130.pls" | grep -Po '(?<=File\d=).+$' | head -n 1 | xargs mpc add;
mpc save "Soma FM - $(echo "$p" | grep -Po '(?<= ).+$')"
mpc clear
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment