Spotify Plugin

If you have a feature you'd like to see in Indigo, post it here. Others can refine the idea if they like. Please keep each topic to one feature or a closely related set of features and don't add other unrelated requests to an existing topic. Use the Hardware Support Requests forum below to request support for some bit of hardware - but be sure to check the 3rd Party Plugins Forum first though to make sure there isn't already a plugin for it.
zacklin
Posts: 2
Joined: Mon Aug 11, 2014 10:58 pm

Spotify Plugin

Post by zacklin »

Hey Guys,

Has there been any updates on a Spotify Plugin? Is there anyone that has integrated Spotify?

Thanks!
- Zack
User avatar
jay (support)
Site Admin
Posts: 18317
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Spotify Plugin

Post by jay (support) »

I don't know that anyone's ever asked before. I'm not even sure if they provide an API. I believe their Mac app is scriptable, so that's an option.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
zacklin
Posts: 2
Joined: Mon Aug 11, 2014 10:58 pm

Re: Spotify Plugin

Post by zacklin »

A Spotify Plugin would be awesome! I know a few users that would love it!
rm2014
Posts: 28
Joined: Sun Sep 14, 2014 11:01 pm

Re: Spotify Plugin

Post by rm2014 »

Hey Zack - any luck getting a spotify plugin? Would be really useful!
mattggarland
Posts: 49
Joined: Sun Jan 06, 2013 11:44 am

Re: Spotify Plugin

Post by mattggarland »

I do quite a lot with Spotify now! I actually sold all my Sonos Gear and replaced it with spotify connect. SO much better.

Anyway ... here's my solution (so far). This script runs every second on a schedule:

Code: Select all

set playState to "blahblahblah"

tell application "Spotify"
	set trackID to id of current track
	set trackPosition to player position
	if player state is playing then
		set playState to "Playing"
	else if player state is paused then
		set playState to "Paused"
	else if player state is stopped then
		set playState to "Paused"
	end if
end tell

tell application "IndigoServer"
	set Secs to trackPosition mod 60 as integer
	set Mins to trackPosition div 60 as integer
	if Secs is 60 then
		set Secs to 0
		set Mins to Mins + 1
	end if
	if Secs is less than 10 then set Secs to "0" & Secs as string
	set Secs to Secs as string
	set value of variable "SpotifyCurrentPosition" to trackPosition as integer
	set value of variable "SpotifyCurrentPositionHuman" to (Mins as string) & ":" & (Secs as string)
end tell

if playState is "Playing" then
	set value of variable "SpotifyCurrentPlaystate" to "Playing"
else if playState is "Paused" then
	set value of variable "SpotifyCurrentPlaystate" to "Paused"
else if playState is "Stopped" then
	set value of variable "SpotifyCurrentPlaystate" to "Stopped"
else
	set value of variable "SpotifyCurrentPlaystate" to "Unknown"
end if
if value of variable "SpotCurrentID" is not trackID then
	
	
	set value of variable "SpotCurrentID" to trackID
	
	
	tell application "Spotify"
		set trackName to name of current track
		set albumName to album of current track
		set artistName to artist of current track
	end tell
	
	log trackName & " by " & artistName & " from album " & albumName & " played"
	
	set value of variable "SpotCurrentTrack" to trackName
	set value of variable "SpotCurrentAlbum" to albumName
	set value of variable "SpotCurrentArtist" to artistName
	tell application "Spotify"
		set aTrack to current track
		set aTrackArtwork to null
		
	end tell
	
	
	
	--begin album art script
	set ArtworkFromSpotify to "Server SSD:Library:WebServer:Documents:albumArt.jpg" as alias
	set SpotifyArtwork to "Server SSD:Library:WebServer:Documents:albumArt.jpg"
	-- Unix versions of the above path strings
	set unixSpotifyArtwork to the quoted form of POSIX path of SpotifyArtwork
	tell application "Spotify"
		set aTrack to current track
		set aTrackArtwork to null
		set aTrackArtwork to artwork of aTrack
		set fileRef to (open for access ArtworkFromSpotify with write permission)
		try
			write aTrackArtwork to fileRef
			close access fileRef
		end try
	end tell
	--end album art script
	
end if
So it reads in the name and playstate and saves them to variables (so I can use them to make control pages that look great).

It also uses the apache server built into OS X, saving the album art to "albumArt.jpg", allowing me to use it as a refreshing image URL in a control page. (Except the most recent spotify update seems to have broken this functionality. The resultant file won't open and doesn't display properly :( - don't know if anyone has any idea why here?

... for control, I have play, pause and back buttons:

just:

Code: Select all

tell application "Spotify"
	play
	pause
	next track
	previous track
	//anything else you can find in the applescript dictionary for spotify :p
end tell
... works good so far :) Worth a look at playing tracks in context ...

limitations I have come across so far:
Theres no way to add songs to playlists or star them.
Specific songs can be played, but not playlists, without running play track BLAH in context BLUP - so you can't rely on playing a playlist unless you're SURE the first song in the playlist is known.

Hopefully might help someone?
stoffergoffer
Posts: 37
Joined: Tue Apr 16, 2013 2:12 am

Re: Spotify Plugin

Post by stoffergoffer »

to play playlists i have successfully used the following code:

Code: Select all

tell application "Spotify"
	set shuffling to true
	play track "spotify:user:spotify:playlist:70P6cQQiiswZWudBTHPBp7"
	next track
end tell
Where the playlist url can be obtained by clicking the 3 dots on a playlist and choose 'copy spotify uri'
pmgendon
Posts: 35
Joined: Mon Apr 20, 2015 11:56 am

Re: Spotify Plugin

Post by pmgendon »

Hey Matt, Solid work with the script,

I wonder if the fact that album art is now in TIFF format could explain the broken part of your script?


pm
morps
Posts: 122
Joined: Sat Nov 01, 2003 9:11 am

Re: Spotify Plugin

Post by morps »

Matt:
It also uses the apache server built into OS X, saving the album art to "albumArt.jpg", allowing me to use it as a refreshing image URL in a control page. (Except the most recent spotify update seems to have broken this functionality. The resultant file won't open and doesn't display properly :( - don't know if anyone has any idea why here?
Is there any reason why you don't just write the file back into the IndigoWebServer directory path? Something like:

Code: Select all

Macintosh HD:Library:Application Support:Perceptive Automation:Indigo 6:IndigoWebServer:images:backgrounds:albumArt.jpg
One less thing to manage (another port, server, etc). That said, I haven't been able to figure out why it's failing as well. I think @pmgendon is onto something that the Spotify . That said, have you (or anyone) tried using a curl approach by passing the Track ID back to the Spotify API and grabbing the file from there? I probably don't even know enough to be dangerous, but check this out:

https://developer.spotify.com/web-api/c ... 18L0Oimnem
the41stside
Posts: 15
Joined: Sat Nov 21, 2015 12:33 pm

Re: Spotify Plugin

Post by the41stside »

Would love some advancements with spotify if anyone has made it further along. I'm looking to put the search function right into a control page. I doubt based on the scripting options for spotify that this is possible but maybe someone knows something I don't. But based on the custom ID's for tracks etc. I don't see anyway to a search outside of using spotify itself.

I work a little with Control 4 automation for other people, which is typically expensive products. That said they're integrating deezer, pandora, spotify etc. right into their master control pages because that's what customers want. I know the indigo community can match this. Any thoughts, I'll take them all.
User avatar
Korey
Posts: 817
Joined: Wed Jun 04, 2008 11:47 am
Location: Henderson, NV

Re: Spotify Plugin

Post by Korey »

+1 for a OSX Spotify Plugin. Not that impressed with Apple Music at this point.
--
Korey
eriass
Posts: 26
Joined: Thu May 12, 2016 4:49 am

Re: Spotify Plugin

Post by eriass »

Here is an update regarding the album covers. Got some help from a dear friend to help me.


--begin album art script

set ArtworkFromSpotify to "HD:Library:Application Support:Perceptive Automation:Indigo 7:IndigoWebServer:images:spotify:albumArt.jpg" as alias
-- Unix versions of the above path strings
set unixSpotifyArtwork to the quoted form of POSIX path of ArtworkFromSpotify

tell application "Spotify"

set aTrack to current track
set aTrackArtwork to null
set aTrackArtwork to artwork url of aTrack

try
do shell script "/usr/bin/curl -s -S -m 30 " & aTrackArtwork & " > " & unixSpotifyArtwork
end try

end tell
--end album art script
bkmar1192
Posts: 274
Joined: Sat Sep 12, 2015 11:23 am

Re: Spotify Plugin

Post by bkmar1192 »

Is anyone actively working on a Spotify plugin using the Spotify API? It is the next project on my list but don't want to start if something is already in development.


Sent from my iPhone using Tapatalk
User avatar
Korey
Posts: 817
Joined: Wed Jun 04, 2008 11:47 am
Location: Henderson, NV

Re: Spotify Plugin

Post by Korey »

bkmar1192 wrote:Is anyone actively working on a Spotify plugin using the Spotify API? It is the next project on my list but don't want to start if something is already in development.


Sent from my iPhone using Tapatalk

Fantastic news!!

Let me know if you need a beta tester!

:D :D :D
--
Korey
User avatar
Stoutjesdijk
Posts: 135
Joined: Sun Dec 21, 2014 4:11 pm
Location: The Netherlands

Re: Spotify Plugin

Post by Stoutjesdijk »

If I wanted to get the album art from Spotify, is there any way I can display that album art through the Sonos plugin? Once I start a spotify playlist (from my phone), the Indigo controls all work, but the album art is not updated...
Best regards,

Mark

Trying to tie it all together...
| Indigo | Plex | NAD M33 | Unifi | LG WebOS | Tado | Sonos | SolarEdge | HUE |
User avatar
Korey
Posts: 817
Joined: Wed Jun 04, 2008 11:47 am
Location: Henderson, NV

Re: Spotify Plugin

Post by Korey »

Stoutjesdijk wrote:If I wanted to get the album art from Spotify, is there any way I can display that album art through the Sonos plugin? Once I start a spotify playlist (from my phone), the Indigo controls all work, but the album art is not updated...

If you use Airfoil, it will grab the album art from Spotify, as well as all the other metadata, Handy Dandy! :D :D

Now if someone would just create a plugin so Indigo knows when spotify is playing! :wink:
Attachments
Screen Shot 2017-10-29 at 8.38.21 AM.PNG
Screen Shot 2017-10-29 at 8.38.21 AM.PNG (319.92 KiB) Viewed 16703 times
--
Korey
Post Reply

Return to “Feature Requests”