How to get data such as that is music playing, tilte, artist from the app (Windows/Mac). There is a option with using Web API but I tested Musixmatch app and it works even when I am offline so connecting to the app is possible somehow.
Spotify is exposing some API that you can use to query the state of your application
For example if you are on an Apple system you can use 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
This example comes from the official documentation that you can find here.
For Windows instead I would say that currently there is no clear way to do it. Once there was Libspotify SDK but it is no longer supported.
It seems that this library is going to be substitute with some new API for Windows/Mac/whatever but for now there are only beta versions for phone OS and I cannot really find anything for Windows.
So it seems that your only option is to use the old version of this library and hope that is still working properly.
Where and how you like to use that data? You can take a look at %AppData% folder in windows. Other than this you may use automation tools like UFT/QTP or Sikuli which you can use to grab data from the Spotify User interface. But WebAPI is best approach
Spotify is caching through the: "c:\users\username\appdata\local\spotify\data" folder. There is probably something in here that can help you.
See PySpotify! It looks like it has support for any operating system that supports Python (including Windows and Mac).
© 2022 - 2024 — McMap. All rights reserved.