I seguenti lavori sull'ultimo macOS che sto usando (High Sierra 10.13.5 Beta) e l'ultimo iTunes (12.7.4.76).
Ho scritto un AppleScript che sta usando UI Scripting e compila un elenco di brani acquistati su iTunes. Lo script aprirà un nuovo documento TextEdit e riempirà i brani in un formato delimitato da virgole e conterrà il numero sequenziale, il nome del brano, l'artista, l'album e la durata del brano. L'output sarà simile a questo:
"Nr","Song Name","Artist","Album","Duration"
"1","Badinerie","Lucero Tena","Lección de castañuelas","1:03"
"2","El colibrí","Lucero Tena","Lección de castañuelas","1:07"
"3","El relicario","Lucero Tena","Lección de castañuelas","1:36"
Eccoloscript:
tellapplication"iTunes" to activate
tell application "TextEdit"
activate
make new document at the front with properties {name:"iTunes purchased.txt"}
delay 1
tell application "System Events" to click menu item "Make Plain Text" of menu 1 of menu bar item "Format" of menu bar 1 of application process "TextEdit"
end tell
tell application "iTunes" to activate
tell application "System Events"
keystroke "1" using {command down}
set w to window "iTunes" of application process "iTunes"
click radio button "Store" of radio group 1 of w
delay 2
set webarea to UI element 1 of scroll area 1 of group 1 of group 1 of splitter group 1 of w
click static text 1 of UI element 1 of group 6 of list 2 of webarea
delay 2
click radio button "All" of tab group 1 of group 2 of webarea
delay 3
click radio button "Songs" of tab group 1 of group 5 of webarea
delay 5
set allRows to UI elements of table 1 of webarea
set entireContent to quote & "Nr" & quote & "," & quote & "Song Name" & quote & "," & quote & "Artist" & quote & "," & quote & "Album" & quote & "," & quote & "Duration" & quote & return
tell application "TextEdit" to activate
repeat with aRow in allRows
if class of aRow is row then
set gr to UI element 1 of group 1 of UI element 2 of aRow
if class of gr is group then
set songNum to value of static text 1 of group 1 of UI element 1 of aRow
set songName to value of static text 1 of group 2 of UI element 2 of aRow
set songArtist to value of static text 1 of group 1 of UI element 1 of UI element 3 of aRow
set album to UI element 1 of UI element 4 of aRow
set songAlbum to ""
if (count of UI elements of album) is greater than 0 then
set songAlbum to value of static text 1 of group 1 of album
end if
set songDuration to ""
set dur to UI element 5 of aRow
if (count of UI elements of dur) is greater than 0 then
set songDuration to value of static text 1 of group 1 of dur
end if
set aLine to quote & songNum & quote & "," & quote & songName & quote & "," & quote & songArtist & quote & "," & quote & songAlbum & quote & "," & quote & songDuration & quote
set entireContent to entireContent & aLine & return
tell application "TextEdit" to set text of front document to entireContent
end if
end if
end repeat
end tell
Il processo non è veloce, sul mio computer ci vuole circa 1 secondo per canzone quindi preparatevi ad aspettare un po '. Inoltre, se inizi a ricevere alcuni errori "fuori indice" prova, mentre lo script è in esecuzione, scorrendo l'elenco dei brani di iTunes in background per assicurarti che l'intero contenuto dell'elenco venga caricato prima di poter accedere a AppleScript.