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

从Spotify应用程序(Windows/Mac)获取数据,spotify,spotify-app,Spotify,Spotify App,如何从应用程序(Windows/Mac)获取音乐播放、倾斜、艺术家等数据。有一个使用Web API的选项,但我测试了Musixmatch应用程序,它甚至在我离线时也能工作,因此可以通过某种方式连接到该应用程序。Spotify通过“c:\users\username\appdata\local\Spotify\data”文件夹进行缓存。这里可能有一些东西可以帮助您。Spotify正在公开一些可以用来查询应用程序状态的API 例如,如果您使用的是苹果系统,则可以使用AppleScript API:

如何从应用程序(Windows/Mac)获取音乐播放、倾斜、艺术家等数据。有一个使用Web API的选项,但我测试了Musixmatch应用程序,它甚至在我离线时也能工作,因此可以通过某种方式连接到该应用程序。

Spotify通过“c:\users\username\appdata\local\Spotify\data”文件夹进行缓存。这里可能有一些东西可以帮助您。

Spotify正在公开一些可以用来查询应用程序状态的API 例如,如果您使用的是苹果系统,则可以使用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
此示例来自您可以找到的官方文档

而不是Windows我要说的是,目前还没有明确的方法可以做到这一点。曾经有,但现在不再支持

这个库似乎将被Windows/Mac/什么的新API所取代,但目前只有手机操作系统的测试版,我真的找不到任何适用于Windows的API


因此,您唯一的选择似乎是使用此库的旧版本,并希望它仍能正常工作。

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

请参见!它似乎支持任何支持Python的操作系统(包括Windows和Mac)。

此实现基于我在回答中提到的“不再支持”库。我想从Spotify的旧版本中重新制作“歌词”功能。Musixmatch也做了同样的事情,但我想在背景上添加艺术家的大图,使它看起来更漂亮。