-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathiTunes.applescript
More file actions
83 lines (68 loc) · 2.15 KB
/
Copy pathiTunes.applescript
File metadata and controls
83 lines (68 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
(*
iTunes Library
v1.0
Dov Frankel, 2013
property LibLoader : load script file ((path to scripts folder from user domain as text) & "Libraries:Library Loader.scpt")
property iTunesLib : LibLoader's loadScript("Libraries:iTunes.applescript")
*)
--my SelectSource("Music")
(*
tell iTunesLib to SelectSource("Music")
*)
-- Select an item in iTunes's sidebar with SourceName (can be a library, playlist, etc.)
on SelectSource(SourceName)
set SourceName to SourceName as text
tell application "iTunes" to activate
tell application "System Events"
tell process "iTunes"
-- Loop through the various Scroll Areas in iTunes until we find the sources list
repeat with i from 1 to 5
try
set libraryScrollArea to scroll area i of window "iTunes"
set libraryList to outline 1 of libraryScrollArea
if "sources" = description of libraryScrollArea as string then
exit repeat
end if
end try
end repeat
repeat with libraryItem in every row of libraryList
set theLabel to value of UI element 1 of libraryItem
if theLabel is equal to SourceName then
select libraryItem
log ("Selected iTunes item '" & theLabel & "'")
return true
end if
end repeat
end tell
end tell
log ("Couldn't find iTunes item '" & SourceName & "'")
return false
end SelectSource
(*
set syncSuccess to iTunesLib's SyncAppleTv("Greedo")
*)
-- Syncs the specified AppleTV
-- Returns true if it was able to sync, false if it was already syncing or not available
on SyncAppleTv(AppleTvName)
set AppleTvName to AppleTvName as text
if not (my SelectSource(AppleTvName)) then
log ("ðtv '" & AppleTvName & "' not found")
return false
end if
tell application "iTunes" to activate
tell application "System Events"
tell process "iTunes"
set syncMenuItem to menu item ("Sync Ò" & AppleTvName & "Ó") of menu 1 of menu bar item "File" of menu bar 1
if syncMenuItem's enabled is true then
log ("Syncing ðtv: " & AppleTvName)
click syncMenuItem
delay 5
return true
else
log ("Not syncing ðtv: " & AppleTvName & " (already syncing)")
return false
end if
end tell
end tell
return false
end SyncAppleTv