Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting data from Spotify app (Windows/Mac)

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.

like image 874
Mateusz Kaflowski Avatar asked Sep 10 '17 16:09

Mateusz Kaflowski


People also ask

How do I access Spotify files on Mac?

Here is how you can navigate to the Spotify folder on your Mac: Open the Spotify application on your Mac and expand the drop-down menu against your name in the top-right corner of the window. Click on Settings and locate Offline songs storage. Check the location mentioned under Offline songs storage.

Is there a desktop app for Spotify for Mac?

Of course! You can download Spotify songs, albums, playlists, and podcasts until you run out of storage space on your device. For the app itself, you can get a Spotify download for Mac, iOS, Android, and Windows.

Why is Spotify taking up so much space PC?

Answer: Spotify stores songs on your devices' cache. This enables the music to start immediately after pressing Play. The amount of music stored in the cache shouldn't keep growing as new songs replace stored songs that haven't been listened to for a while.

Where does Spotify store local files?

Launch the Spotify desktop app and head to Menu > Edit > Preferences. Then scroll down the settings page and turn on the “Show Local Files” switch. After turning it on, you will see a few other options including showing songs from your “Downloads” and “Music Library” folder.


1 Answers

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.

like image 184
rakwaht Avatar answered Oct 15 '22 02:10

rakwaht