Search code examples
applescriptitunes

Applescript list of loved albums


How can i, as the title indicates, get a list of all loved albums from iTunes in applescript.

I have a code that works for playlist but it is not as simple as changing the word playlist to album because the album name(as well as its loved status) is stored as part of the song, where as a playlist is a list of songs.

Currently i have:

    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

Also a list of all followed artists would be great


Solution

  • You can do this only with a repeat loop by getting all loved tracks and create two lists for albums and artists

    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"