Insert iTunes Data into Post
-
Comments:
- here.
I used to use ecto to paste all of my entries on my blog, but with Blogsome’s XMLRPC issue, I have to use a browser. But it would be nice to automatically get the name and information about my currently playing iTunes track, just like ecto used to do. I wrote an AppleScript that does this, and, inserts the data in at the insertion point for you. Because it’s intended to be run from the Script Menu, and everything run from there runs as “System Events”, I had to hard code in the browser name. If you use another browser, just replace the second line with whatever your browser is called.
1 property star : «data utxt2605» as Unicode text
2 property browser : "Camino"
3 on run {}
4
5 tell application "System Events"
6 try
7 get process "iTunes"
8 on error
9 return "No Track"
10 end try
11 end tell
12
13 tell application "iTunes"
14 set theTrack to current track
15 set theArtist to artist of theTrack
16 set theAlbum to album of theTrack
17 set theRating to rating of theTrack
18 set theTrack to name of theTrack
19 end tell
20
21 set theString to "<p class=’itunes’> " & theTrack & " • <a href='http://www.google.com/search?q=%22" & theArtist & "%22>" & theArtist & "</a> • <a href=’http://www.google.com/search?q=%22" & theAlbum & "%22>" & theAlbum & "</a> " & myRating(theRating)
22 set the clipboard to theString
23
24 tell application browser
25 activate
26 tell application "System Events" to keystroke "v" using {command down}
27 end tell
28 end run
29
30 on myRating(theRating)
31 set theResult to ""
32 set theTimes to (theRating - 9) / 20 as integer
33 repeat theTimes times
34 set theResult to theResult & star
35 end repeat
36 return theResult
37 end myRating