在Applescript中,从Spotify中搜索播放列表信息,并启用/禁用随机播放

时间:2016-05-10 00:58:52

标签: applescript spotify

我知道AppleScript for Spotify中有许多命令,例如简单的playpause命令,但我如何从Spotify中提取播放列表的信息,并将其粘贴到choose from list?我希望它能从您收听的任何地方收集所有歌曲,并将其粘贴到choose from list中,以便您可以选择要收听的歌曲。这甚至可能吗?我可以做类似的事情吗?

另外,你如何启用/禁用改组?

此外,有没有办法通过AppleScript搜索Spotify?

我不确定这些是否可行,Google现在没有任何相关信息。有谁知道怎么做?

1 个答案:

答案 0 :(得分:1)

Spotify AppleScript实现没有获取播放列表信息的特定命令 - 它只显示“当前曲目”以获取有关当前播放曲目的信息,以及播放下一曲目的“下一曲目”。您可以解决此限制,以构建包含当前播放列表中所有曲目的AppleScript数组。

set trackNameList to {}
set trackIDList to {}

tell application "Spotify"
    activate

    set shuffling to false
    set repeating to true
    set sound volume to 0

    if player state is not playing then
        playpause
    end if

    set trackID to spotify url of current track
    repeat while trackIDList does not contain trackID
        set end of trackIDList to trackID
        set end of trackNameList to name of current track
        next track
        delay 1 -- otherwise Spotify misbehaves
        set trackID to spotify url of current track
    end repeat

end tell

tell me to activate
set chosenNames to choose from list trackNameList without multiple selections allowed
set chosenName to (item 1 of chosenNames) as string

repeat with i from 1 to count of trackNameList
    set itsName to (item i of trackNameList) as string
    if itsName is chosenName then
        exit repeat
    end if
end repeat

set trackID to (item i of trackIDList) as string

tell application "Spotify"
    activate
    set sound volume to 100
    play track trackID
end tell

在Spotify中搜索没有AppleScript支持。