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

Mat*_*ski 10 spotify spotify-app

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

rak*_*aht 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
Run Code Online (Sandbox Code Playgroud)

此示例来自您可以在此处找到的官方文档.

对于Windows而言,我会说现在没有明确的方法可以做到这一点.一旦有Libspotify SDK但不再支持它.

似乎这个库将取代一些新的Windows/Mac/API,但现在只有手机操作系统的beta版本,我真的找不到任何适合Windows的版本.

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


小智 0

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