Skip to content

Instantly share code, notes, and snippets.

@chimo
Created December 11, 2012 23:51
Show Gist options
  • Select an option

  • Save chimo/4263498 to your computer and use it in GitHub Desktop.

Select an option

Save chimo/4263498 to your computer and use it in GitHub Desktop.
bash script to post a gnufm user's top5 artists to statusnet.
#!/bin/bash
# gnufm script
# NOTE: Change these:
fmuser=gnufm_username # Your gnu-fm username
fmhost=gnufm_host # Your gnu-fm host (ex: libre.fm)
snuser=sn_username # Your SN username
snpass=sn_password # Your SN password
snhost=sn_host # Your SN host (ex: identi.ca)
artistlist=$(curl -s "http://$fmhost/2.0/?method=user.getTopArtists&user=$fmuser&period=7day&limit=5"| \
grep '<name>' | awk -F'<name>' '{print $2}' | awk -F'</name>' '{print $1}' |sed 's/\&amp\;/and/i')
# Replace newlines with commas
artistlist=${artistlist//$'\n'/, }
message=$(echo "#test My #top5 artists this week: $artistlist #gnufm #music")
case $1 in
-t)
echo "$artistlist"
;;
*)
curl -s --basic --output /dev/null -u $snuser:$snpass -d status="$message&source=gnufmscript" http://$snhost/api/statuses/update.json
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment