Skip to content

Instantly share code, notes, and snippets.

@gmcmillan
Created November 29, 2012 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmcmillan/4170583 to your computer and use it in GitHub Desktop.
Save gmcmillan/4170583 to your computer and use it in GitHub Desktop.
rdio.scpt
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning
on shortenUrl(str)
set curl_cmd to "curl -s https://www.googleapis.com/urlshortener/v1/url"
set json to " -H 'Content-Type: application/json' -d '{\"longUrl\": \"" & str & "\"}'"
set grep_cmd to "grep -Eo 'http:\\/\\/goo\\.gl\\/[0-9A-Za-z]*'"
set command to curl_cmd & json & " | " & grep_cmd
do shell script command
end shortenUrl
on substitute()
if appIsRunning("Rdio") then
tell application "Rdio"
set rdio_artist to artist of the current track
set rdio_track to name of the current track
set rdio_url to "http://rdio.com" & rdio url of the current track
end tell
if rdio_artist is not "" and rdio_track is not "" and rdio_url is not "" then
return "♫ " & rdio_artist & " - " & rdio_track & " (" & shortenUrl(rdio_url) & ")"
end if
end if
end substitute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment