(*=== Properties and Globals===*)
property theDateofLastSync : "" -- date of last sync
property theOtherMachine : "" -- address of other machine
(*=== Main Run ===*)
if theDateofLastSync is "" then set theDateofLastSync to ((current date) - 1 * days) -- force date for first run
if theOtherMachine is "" then
display dialog "Please enter address of other Mac" default answer "eppc://10.0.1.193"
set theOtherMachine to text returned of the result
end if
-- chat with other machine
set GotsomeTracks to true
try
with timeout of 30000 seconds
tell application "itunes" of machine theOtherMachine
using terms from application "iTunes"
activate
set theListofTracks to location of file tracks of library playlist 1 where date added > theDateofLastSync
say "Brian is syncing"
end using terms from
end tell
end timeout
on error
set GotsomeTracks to false
say "No tracks"
end try
-- back to this Machine
set SyncedOK to false
if GotsomeTracks then
say "Got some tracks"
set SyncedOK to true
try
tell application "iTunes"
if (count of items of theListofTracks) is greater than 0 then
repeat with alocation in theListofTracks
add alocation to library playlist 1
end repeat
end if
end tell
on error
set SyncedOK to false
end try
end if
-- save sync date if all ok
if SyncedOK then set theDateofLastSync to current date
say "I'm done now"