Jump to content

Applescript: Post your currently playing song.


WaldMeister
 Share

3 posts in this topic

Recommended Posts

Hi,

 

So i was searching for an alternative for the AMIP plugin i used in the past in Windows. After some googling i found an applescript which does the same. 

 

Copied from the site

 

For quite some time Mac users where searching for a way to paste the currently playing song from iTunes in chat messages etc. I never thought about it much but recently a friend of mine, who was a former AMIP user on Windows, needed a similar functionality under OS X. Together we constructed a working solution.

So here it is the AMIP alternative for Mac:

    • Open Automator and start a new “Service”
    • Choose “no input” for “Service receives”
    • Drag the “Run AppleScript” Action into the workflow
    • Paste in the following and edit the output in (green) to your hearts desire
on run
try
tell application "iTunes"
set songTitle to the name of the current track
set songArtist to the artist of the current track
set songAlbum to the album of the current track
set songYear to the year of the current track
set the clipboard to "np:" & the songArtist & " - " & songTitle & " \"" & songAlbum & ", " & songYear & "\""
end tell
end try
try
set the clipboard to Unicode text of (the clipboard as record)
on error errMsg
display dialog errMsg
end try
tell application "System Events"
key code 9 using {command down}
end tell
end run
  • Save the service. I named mine “music” (creative isn’t it? simple-smile.png )
  • Now your able to run the service from every application’s menu under “Services”. Be sure to have your cursor in a text field because the service will immediately paste in the constructed string.
  • If you’re in a super nerdy mood today, you can also give your service a keyboard shortcut.
    Go to “System Preferences”, open “Keyboard”, go to “Keyboard Shortcuts” and set your desired Hotkey. (mine’s CMD + SHIFT + M)

 

I simplified mine a little: 

on run
 tell application "iTunes"
 set songTitle to the name of the current track
 set songArtist to the artist of the current track
 set songAlbum to the album of the current track
 set songYear to the year of the current track
 set the clipboard to "Now Playing: " & the songArtist & " - " & songTitle & " \"" & songAlbum & ", " & songYear & "\""
 end tell
 set the clipboard to Unicode text of (the clipboard as record)
 tell application "System Events"
 key code 9 using {command down}
 end tell
end run

And set the hotkey control + z to paste the song. 

The result: 

Now Playing: The All-American Rejects - Gives You Hell "Radio 538 Hitzone 50, 2009"

More can be added, but for now this is what i wanted. 

 

Credit for this go to Florian Beer

 

post-1090626-0-85395700-1438802827_thumb.png

post-1090626-0-04112500-1438802837_thumb.png

  • Like 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...