Script To Retrieve iTunes Information

S

Stu Mark

I've looked, but have not found, so I ask you kind folk:

Is there an Entourage script that will retrieve information from iTunes and
copy it into the clipboard? In other words, I'd really like to automate the
process of adding what my current iTunes song is to the end of my Usenet
posts.

Stu
(who appreciates any help)

NP: Indian Sunset by Elton John
 
B

Barry Wainwright

I've looked, but have not found, so I ask you kind folk:

Is there an Entourage script that will retrieve information from iTunes and
copy it into the clipboard? In other words, I'd really like to automate the
process of adding what my current iTunes song is to the end of my Usenet
posts.

Stu
(who appreciates any help)

NP: Indian Sunset by Elton John


This should do it:

http://tinyurl.com/7sxc9

tell application "System Events" to set iTunesRunning to ("iTunes" is in
name of every process)
if iTunesRunning then
tell application "iTunes"
if player state is playing then
set theMessage to "Currently Playing " & name of current track &
" in iTunes"
else
set theMessage to "iTunes is open, but not playing anything!"
end if
end tell
else
set theMessage to "iTunes is not running today :("
end if
try
tell application "Microsoft Entourage" to set selection to theMessage &
return
end try



iTunes is open, but not playing anything!
 
S

Stu Mark

This should do it:

http://tinyurl.com/7sxc9

tell application "System Events" to set iTunesRunning to ("iTunes" is in name
of every process)
if iTunesRunning then
tell application "iTunes"
if player state is playing then
set theMessage to "Currently Playing " & name of current track & "
in iTunes"
else
set theMessage to "iTunes is open, but not playing anything!"
end if
end tell
else
set theMessage to "iTunes is not running today :("
end if
try
tell application "Microsoft Entourage" to set selection to theMessage &
return
end try



iTunes is open, but not playing anything!

---------------------

Thanks, but that didn¹t quite do it for me (I forget why... I¹m sure your
script was fine, it just didn¹t give me the results I was looking for.
Really, it¹s me, not you).... However, I got one that did exactly what I
needed... Here¹s the script, in case anyone else wants to do it:


property track_title : {}
property track_artist : {}


on run
with timeout of 120 seconds
tell application "iTunes"
if player state is playing then
set playing_flag to true
else
set playing_flag to false
end if
end tell


if playing_flag is false then
my alert_itunes_stopped()
else
tell application "iTunes"
set current_track to current track
if class of current track is URL track then
my get_info_urltrack(current_track)
else
my get_info_track(current_track)
end if
end tell
end if
end timeout
end run


on get_info_track(current_track)
tell application "iTunes"
set track_title to name of current_track as string
set track_artist to artist of current_track as string
end tell

if track_artist is "" then
set track_artist to "an unknown artist" as string
end if

tell application "iTunes"
if exists playlist "€Charts-O-Mat€" then
set com_playlist to true
else
set com_playlist to false
end if
end tell

if com_playlist is true then
my get_charts_info(track_title)
else
my fill_clipboard()
end if
end get_info_track


on get_info_urltrack(current_track)
tell application "iTunes"
set track_title to name of current_track as string
set track_address to address of current_track
end tell

set the_report to "Currently listening to \"" & track_title & "\" ->
URL: " & track_address
set the clipboard to the_report as text

tell me
activate
display dialog "Successfully pasted the track info to the
clipboard." buttons {"Okay"} default button 1 with icon note giving up after
2
end tell
end get_info_urltrack


on get_charts_info(track_title)
tell application "iTunes"
set the_proof to count of tracks in playlist "€Charts-O-Mat€"
if the_proof > 0 then

try
set search_track to index of every track in playlist
"€Charts-O-Mat€" whose name is track_title as list


if search_track is not {} then
set search_track to item 1 of search_track
set count_tracks to count of tracks in playlist
"€Charts-O-Mat€"

set the_report to (("Currently listening to \"" &
track_title & "\" by " & track_artist & "." & " Ranked #" & search_track as
string) & " on my personal charts (" & count_tracks as string) & " tracks)."
set the clipboard to the_report as text

tell me
activate
display dialog "Successfully pasted the track info
to the clipboard." buttons {"Okay"} default button 1 with icon note giving
up after 2
end tell
else
my fill_clipboard()
end if
on error
my fill_clipboard()
end try

else
my fill_clipboard()
end if
end tell
end get_charts_info


on fill_clipboard()
set the_report to "NP: " & track_title & " by " & track_artist & ""
set the clipboard to the_report as text

tell me
activate
display dialog "Successfully pasted the track info to the
clipboard." buttons {"Okay"} default button 1 with icon note giving up after
2
end tell
end fill_clipboard


on alert_itunes_stopped()
tell me
activate
display dialog "Sorry, iTunes is currently not playing songs to
entertain you..." buttons {"Okay"} default button 1 with icon stop giving up
after 10
end tell
end alert_itunes_stopped
 
Top