#!/bin/bash # File: lastfm.sh # Date: 28 May 2012 # Author: Jason Charney (jrcharneyATgmailDOTcom) # Info: Rapid query and play of Last.FM stations in the console. # Requires: shell-fm # Usage: Put this in your home folder. chmod u+x lastfm.sh; mv lastfm.sh lastfm ; Type ? for a list of commands. # lastfm Keyword Query # See also: irc # Note: If things aren't working try, you probaby have a proxy going. For now use # unset http_proxy # More than likely privoxy is wrecking things if it is not connecting to the server. if [ -z $1 ]; then # Play the default station shell-fm else if [ -z $2 ]; then echo "ERROR: No Query" exit 1 fi case $1 in # Search for "a"|"artist") kw="artist" ;; # an artist "as"|"similarartists") kw="artist" ; attr="similarartists" ;; # similar artists "u"|"user") kw="user" ;; # a user "ul"|"userloved") kw="user" ; attr="loved" ;; # music a user loves? "up"|"userpersonal") kw="user" ; attr="personal" ;; # a user profile? "upl"|"uplay"|"userplaylist") kw="user" ; attr="playlist" ;; # a user playlist "ur"|"urec"|"userrecommended") kw="user" ; attr="reccommended" ;; # music recommended by a user? "g"|"globaltags") kw="globaltags" ;; # global tag "t"|"tag") kw="tag" ;; # a tag. * is a wildcard to separate tags. *) echo "ERROR: Invalid Keyword." exit 1 ;; esac shift if [ -z $attr ]; then link=$(echo "lastfm://${kw}/$@" | sed 's/ /+/g'); else link=$(echo "lastfm://${kw}/$@/${attr}" | sed 's/ /+/g'); fi echo "play $link" shell-fm $link fi