【问题标题】:In Applescript, Retrive playlist information from Spotify, and enable/disable shuffling在 Applescript 中,从 Spotify 中检索播放列表信息,并启用/禁用随机播放
【发布时间】:2016-05-10 00:58:51
【问题描述】:

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

另外,您将如何启用/禁用随机播放?

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

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

【问题讨论】:

  • 你可以看到关于使用他们的 api... 我找到了 this jsfiddle,它显示了如何搜索 spotify。您总是可以看到有关使用 applescript 打开浏览器并通过使用 javascript 更新空白窗口将其发送到“自定义”页面...但那时您几乎没有使用 applescript。

标签: applescript spotify


【解决方案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。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    • 2023-01-23
    • 2012-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多