Reputation: 3827
So that they appear correctly (and usefully!) sorted when viewed from an AppleTV (2nd gen), I'm trying to programmatically set the 'Release Date' of all the TV episodes in my iTunes library. Unfortunately, that field is r/o on the track object, so I'm resorting to setting it via UI scripting. I've gone through the discovery process of finding the UI element names, but I just can't quite get the desired element to accept input. It has the focus, but key presses don't seem to reach it.
tell application "iTunes"
tell frontmost to activate
if selection is not {} then
set originalSelection to selection
repeat with theEpisode in originalSelection
set addedDate to (date added of theEpisode)
if (release date of theEpisode) is missing value then
tell application "System Events"
tell process "iTunes"
tell menu bar 1
tell menu bar item "Edit"
tell menu "Edit"
click menu item "Get Info"
end tell
end tell
end tell
delay 1
tell window "TV Show Info"
activate
tell scroll area 1
tell group 1
set focused of UI element 2 to true
tell window "TV Show Info" to activate
keystroke "1"
end tell
end tell
end tell
end tell
end tell
-- I'd prefer to just do this, but the property is r/o
-- set release date of theEpisode to (date added of theEpisode)
end if
end repeat
end if
end tell
There's a few redundant, ineffective, desperate attempts in there to get the date field to truly take the focus. While it does get highlighted as being the active element, it still doesn't take keypresses. What am I missing?
(This is on iTunes 12.4.1.6, if that makes any difference)
Upvotes: 0
Views: 120
Reputation: 7191
But, it's possible on iTunes 12.4.1.6, probably they have forgotten to change it in the dictionary.
tell application "iTunes"
repeat with theEpisode in (get selection)
if (release date of theEpisode) is missing value then
set addedDate to (date added of theEpisode)
set release date of theEpisode to addedDate
end if
end repeat
end tell
Upvotes: 1