Getting data from Spotify app (Windows/Mac)
Asked Answered
B

4

10

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.

Borehole answered 10/9, 2017 at 16:28 Comment(0)
R
6

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.

Razo answered 20/9, 2017 at 14:52 Comment(0)
S
1

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

Stereoscope answered 20/9, 2017 at 22:10 Comment(1)
I want to remake "Lyrics" feature from old versions of Spotify. Musixmatch do the same thing but I want to add big picture of artist on the background to make it look nicer.Borehole
T
0

Spotify is caching through the: "c:\users\username\appdata\local\spotify\data" folder. There is probably something in here that can help you.

Testicle answered 20/9, 2017 at 9:20 Comment(0)
M
0

See PySpotify! It looks like it has support for any operating system that supports Python (including Windows and Mac).

Misesteem answered 21/9, 2017 at 7:38 Comment(1)
this implementation is based on the "no longer supported" library that I was mention in my answerRazo

© 2022 - 2024 — McMap. All rights reserved.