Created
November 8, 2012 11:31
-
-
Save Zettt/4038282 to your computer and use it in GitHub Desktop.
AppleScript that gets currently playing track with title and name and whatnot and returns it only if iTunes is running. Useful for TextExpander snippets. (Include in optional section)
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
tell application "System Events" | |
if not (exists process "iTunes") then return | |
end tell | |
tell application "iTunes" | |
tell playlist "Rating = 5" | |
set trackCount to count of tracks | |
set randomTrackNumber to random number from 1 to trackCount | |
set trackTitle to name of track randomTrackNumber | |
set trackArtist to artist of track randomTrackNumber | |
set trackAlbum to album of track randomTrackNumber | |
end tell | |
end tell | |
return "#nowplaying: " & trackTitle & " by " & trackArtist & " from " & trackAlbum |
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
tell application "System Events" if not (exists process "iTunes") then return end tell tell application "iTunes" tell playlist "Rating = 5" set trackCount to count of tracks set randomTrackNumber to random number from 1 to trackCount set trackTitle to name of track randomTrackNumber set trackArtist to artist of track randomTrackNumber set trackAlbum to album of track randomTrackNumber end tell end tell return "#nowplaying: " & trackTitle & " by " & trackArtist & " from " & trackAlbum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment