Get link to currently playing Spotify track via AppleScript

I was looking around for a means to grab the URL of the currently playing track in Spotify earlier, but couldn't find anything.

I rattled together an AppleScript to do just that and copy the result, including the track and artist name, to your clipboard.

tell application 'Spotify'
set theTrack to name of the current track
set theArtist to artist of the current track
set theAlbum to album of the current track
set track_id to id of current track
end tell
set AppleScript's text item delimiters to ':'
set track_id to third text item of track_id
set AppleScript's text item delimiters to {''}
set realurl to ('http://open.spotify.com/track/' & track_id)
set theString to theTrack & ' - ' & theArtist & ': ' & realurl
set the clipboard to theString

Chris Miller is a developer and designer living and working in the South of Scotland. He's worked in various advertising agencies throughout his career before he started up his own Web Development company, Red Wolf Digital, in 2012.