Created
November 29, 2012 17:27
-
-
Save gmcmillan/4170583 to your computer and use it in GitHub Desktop.
rdio.scpt
This file contains 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
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