从Spotify应用程序获取数据(Windows / Mac)

时间:2017-09-10 16:28:37

标签: spotify spotify-app

如何从应用程序(Windows / Mac)获取音乐播放,倾斜,艺术家等数据。有一个使用Web API的选项,但我测试了Musixmatch应用程序,即使我处于离线状态也能正常工作,因此可以某种方式连接到应用程序。

4 个答案:

答案 0 :(得分:6)

Spotify公开了一些可用于查询应用程序状态的API

例如,如果您使用的是 Apple系统,则可以使用AppleScript API:

-- Creates a notification with information about the currently playing track

-- Main flow
set currentlyPlayingTrack to getCurrentlyPlayingTrack()
displayTrackName(currentlyPlayingTrack)

-- Method to get the currently playing track
on getCurrentlyPlayingTrack()
  tell application "Spotify"
    set currentArtist to artist of current track as string
    set currentTrack to name of current track as string

    return currentArtist & " - " & currentTrack
  end tell
end getCurrentlyPlayingTrack

-- Method to create a notification
on displayTrackName(trackName)
  display notification "Currently playing " & trackName

  -- A delay is set added make sure the notification is shown long enough before the script ends
  delay 1

end displayTrackName

此示例来自您可以找到here的官方文档。

对于Windows而言我想说目前没有明确的方法可以做到这一点。一旦有Libspotify SDK但不再支持它。

似乎这个库将取代一些新的Windows / Mac / API,但现在只有手机操作系统的测试版,我真的找不到适合Windows的东西。

所以看来你唯一的选择是使用这个库的旧版本,并希望它仍能正常工作。

答案 1 :(得分:1)

您希望在何处以及如何使用该数据?您可以在Windows中查看%AppData%文件夹。除此之外,您可以使用UFT / QTP或Sikuli等自动化工具,您可以使用这些工具从Spotify用户界面获取数据。但WebAPI是最好的方法

答案 2 :(得分:0)

Spotify通过以下方式缓存:" c:\ users \ username \ appdata \ local \ spotify \ data"夹。这里可能有一些东西可以帮助你。

答案 3 :(得分:0)

PySpotify!看起来它支持任何支持Python的操作系统(包括Windows和Mac)。