Created
December 11, 2012 23:51
-
-
Save chimo/4263498 to your computer and use it in GitHub Desktop.
bash script to post a gnufm user's top5 artists to statusnet.
This file contains hidden or 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
| #!/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/\&\;/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