#!/bin/sh if [[ "$1" = "" ]] ; then echo -e "\E[28;1mUsage: ./lastfm.sh [username]" exit fi echo -e "\E[22;1m$1's recent tracks:" wget -qO - http://ws.audioscrobbler.com/1.0/user/$1/recenttracks.txt > lasttxt COUNT=$(cat lasttxt | wc -l) if [[ "$COUNT" = "0" ]] ; then echo -e "\E[31;1mSorry!" exit fi COUNTER=0 while [ $COUNTER -lt $COUNT ]; do let COUNTER=COUNTER+1 EPOCH=$(cat lasttxt | cut -d "," -f 1 | sed -n $COUNTER'p') DATE=$(perl -e "print scalar(localtime($EPOCH))") INF=$(cat lasttxt | cut -d "," -f 2 | sed -n $COUNTER'p') echo -e '\E[31;1m'$INF '\E[34;1m'$DATE '\E[30;1m'$EPOCH done rm lasttxt