Skip to content

Instantly share code, notes, and snippets.

@SydLambert
Created October 9, 2022 16:53
Show Gist options
  • Save SydLambert/ba3f41f6f9e800a8e88f2ba664243ce5 to your computer and use it in GitHub Desktop.
Save SydLambert/ba3f41f6f9e800a8e88f2ba664243ce5 to your computer and use it in GitHub Desktop.
Download the playlist files for all SomaFM stations into the current directory
#!/usr/bin/env sh
curl -s https://somafm.com/channels.xml | grep -Po '((?<=<title><!\[CDATA\[).+?(?=\])|(?<=id=").+?(?="))' | sed 'N;s/\n/ /' | while read -r p; do
stationName=$(echo "$(echo "$p" | grep -Po '(?<= ).+$')" | perl -ple '$_=lc; s/[^\w\s]//g; s/ /-/g')
echo "Downloading $stationName"
curl -s "https://somafm.com/$(echo "$p" | grep -Po '^.+?(?= )')130.pls" > "$stationName.pls"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment