Los siguientes trabajos funcionan en la última versión de macOS que estoy usando (High Sierra 10.13.5 Beta) y la última versión de iTunes (12.7.4.76).
He escrito un AppleScript que usa scripts de UI y compila una lista de canciones compradas en iTunes. La secuencia de comandos abrirá un nuevo documento TextEdit y completará las canciones en un formato delimitado por comas y contendrá el número secuencial, el nombre de la canción, el artista, el álbum y la duración de la canción. La salida será similar a esta:
"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"
Aquíestáelscript:
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
El proceso no es rápido, en mi computadora toma aproximadamente 1 segundo por canción, así que prepárate para esperar un rato. Además, si comienza a obtener algunos errores "fuera de índice", mientras se ejecuta el script, desplace la lista de canciones de iTunes en segundo plano para asegurarse de que todo el contenido de la lista esté cargado antes de que AppleScript acceda a él.