喜爱专辑的 Applescript 列表

Applescript list of loved albums

如标​​题所示,如何在 applescript 中从 iTunes 获取所有喜爱的专辑列表。

我有一个适用于播放列表的代码,但它不像将单词 playlist 更改为 album 那样简单,因为专辑名称(以及它的喜爱状态)存储为一部分歌曲的列表,其中播放列表是歌曲列表。

目前我有:

    tell application "iTunes" to set PLs to the name of every playlist whose
        loved is true as text
    set PL to (choose from list PLs with title "Playlist") as text

最好能列出所有关注的艺术家

您只能通过重复循环来完成此操作,方法是获取所有喜欢的曲目并为专辑和艺术家创建两个列表

set lovedAlbums to {}
set lovedArtists to {}
tell application "iTunes"
    set lovedTracks to every track whose loved is true
    repeat with aTrack in lovedTracks
        tell album of aTrack to if lovedAlbums does not contain it then set end of lovedAlbums to it
        tell artist of aTrack to if lovedArtists does not contain it then set end of lovedArtists to it
    end repeat
end tell
set TID to text item delimiters
set text item delimiters to return
set lovedAlbumText to lovedAlbums as text
set lovedArtistsText to lovedArtists as text
set text item delimiters to TID
display dialog lovedAlbumText & return & return & lovedArtistsText buttons {"Cancel", "OK"} default button "OK"