Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
Spotify (api is partially broken)
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Spotify
It was a while ago since I wrote this plugin, I need to check if the plugin itself keeps track of song changes,
Otherwise it sounds as a good idea to create such an event. This event could be used as you say.
Would it be a good idea to keep the information about the actual song in the payload?
BestR
Otherwise it sounds as a good idea to create such an event. This event could be used as you say.
Would it be a good idea to keep the information about the actual song in the payload?
BestR
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
Re: Spotify
A good payload could be something like
"song - artist - duration"
if possible maby even as " u'songname' u'artistname' u'duration' " this would i believe alow for using payload[0] [1] [2] to get specific? so if i want to send it out to webserver / commandfusion or so it could easly be formated.
though you can do that with the get song function in anyway so maby not nessesary.
But atleast getting an event to tell eventghost the track changed. then you can use that to trigger get song name anyway...
Another wounderfull feature would be to start playing a specific playlist.
Like say i come home and want some nice relaxing music i click the button on my controllunit, it sends to eventghost that triggers playing that music.
The day after i come home, its friday and i want to get in the mood for the nights party so i want club music for example and i then just press that button on my controllunit.
"song - artist - duration"
if possible maby even as " u'songname' u'artistname' u'duration' " this would i believe alow for using payload[0] [1] [2] to get specific? so if i want to send it out to webserver / commandfusion or so it could easly be formated.
though you can do that with the get song function in anyway so maby not nessesary.
But atleast getting an event to tell eventghost the track changed. then you can use that to trigger get song name anyway...
Another wounderfull feature would be to start playing a specific playlist.
Like say i come home and want some nice relaxing music i click the button on my controllunit, it sends to eventghost that triggers playing that music.
The day after i come home, its friday and i want to get in the mood for the nights party so i want club music for example and i then just press that button on my controllunit.
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Spotify
Yes, understood,
Regarding further features, I just have to obey the limits in the api (pytify.py) I'm using for this...
BR
Regarding further features, I just have to obey the limits in the api (pytify.py) I'm using for this...
BR
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Spotify
Okay, here is a version that fires events
- when the artist/track changes
- when nothing is played
I think the second event is also needed to allow easy updates of GUI's when nothing is played, otherwise the last played track will remain in the GUI (if you use websockets or CommandFusion, you can use both events to update the page elements correctly)
Typical events look like this in my tests:
For the other requested features,
- duration is not available
- it is unfortunately not possible with the api I use to select and play a specific playlist.
EDIT: Deleted version, see below
BR Walter
- when the artist/track changes
- when nothing is played
I think the second event is also needed to allow easy updates of GUI's when nothing is played, otherwise the last played track will remain in the GUI (if you use websockets or CommandFusion, you can use both events to update the page elements correctly)
Typical events look like this in my tests:
Code: Select all
15:54:44 MySpotify.CurrentArtistTrack ['Not playing anything...', '']
15:54:46 MySpotify.CurrentArtistTrack ['Lana Del Rey', 'Without You']
- duration is not available
- it is unfortunately not possible with the api I use to select and play a specific playlist.
EDIT: Deleted version, see below
BR Walter
Last edited by krambriw on Mon Dec 30, 2013 7:16 am, edited 1 time in total.
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
Re: Spotify
I have a working but not that good solution for starting specific playlists in Spotify with EG (see below). It works for me if Spotify is already running. You can get the string inside the "Copy string to clipboard:"-action if you right click the playlist you would like to play and choose "Copy Spotify URI".
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1640">
<Folder Name="SpotifyPlayPlaylist" Expanded="True">
<Macro Name="SpotifyPlayPlaylist1000Matti" Expanded="True">
<Action>
System.Execute(u'C:\\Users\\optimalt\\AppData\\Roaming\\Spotify\\spotify.exe', u'', 0, False, 2, u'', False)
</Action>
<Action>
EventGhost.Wait(3.0)
</Action>
<Action>
Window.SendKeys(u'{Tabulator}', False)
</Action>
<Action>
System.SetClipboard(u'spotify:user:chops:playlist:4y9iMsycGTbGcdgun8M8Cj')
</Action>
<Action>
Window.SendKeys(u'{Ctrl+L}', False)
</Action>
<Action>
Window.SendKeys(u'{Ctrl+V}', False)
</Action>
<Action>
Window.SendKeys(u'{Return}', False)
</Action>
<Action>
Window.SendKeys(u'{Tabulator}', False)
</Action>
<Action>
Window.SendKeys(u'{Return}', False)
</Action>
<Action>
Window.SendKeys(u'{Ctrl+L}', False)
</Action>
<Action>
Window.SendKeys(u'{Backspace}', False)
</Action>
<Action>
Window.SendKeys(u'{Tabulator}', False)
</Action>
<Action>
Window.FindWindow(u'spotify.exe', None, None, None, None, None, False, 0.0, 2)
</Action>
<Action>
Window.Minimize()
</Action>
</Macro>
</Folder>
</EventGhost>Re: Spotify
Update: the plugin only give me triggers in EG if spotify was running when EG started.
any idea why this would be?
any idea why this would be?
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Spotify
Hi,
Thanks for reporting back.
I saw some issues with my code so I have improved and hopefully made it work better. In my tests, I can now start EG and the Spotify plugin without problems independent if Spotify is already running or not. I can Start and Terminate Spotify using the plugin actions or via direct commands to the application and I do receive events when I change tracks (and pause/stop playing).
EDIT: Deleted version, see below
BR
Thanks for reporting back.
I saw some issues with my code so I have improved and hopefully made it work better. In my tests, I can now start EG and the Spotify plugin without problems independent if Spotify is already running or not. I can Start and Terminate Spotify using the plugin actions or via direct commands to the application and I do receive events when I change tracks (and pause/stop playing).
EDIT: Deleted version, see below
BR
Last edited by krambriw on Mon Dec 30, 2013 7:15 am, edited 1 time in total.
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
Re: Spotify
It still only gives me trigger eventss if spotify was already running when EG starts.
If i then terminate spotify to start it again i wont get events in EG.
same goes if i start EG without spotify running and then start it, no events.
If i then terminate spotify to start it again i wont get events in EG.
same goes if i start EG without spotify running and then start it, no events.
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Spotify
w7 64 bit?
I have only tested with Vista 32 bit
I have only tested with Vista 32 bit
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Spotify
Now also tested with w7 64 bit,
See your problems, working only if Spotify is already started AND you run EG as admin (you have to run EG as admin, otherwise access right limitation prevents EG from controlling Spotify and also preventing EG from saving it's configurations).
In w7 64 bit, a lot of problems with access rights is preventing previous working solutions from functioning...I do not know, maybe setting up user accounts somehow could solve the problems. You have to investigate if you can find a solution to the access rights problems, use a 32 bit environment or live with this limitation
BR
See your problems, working only if Spotify is already started AND you run EG as admin (you have to run EG as admin, otherwise access right limitation prevents EG from controlling Spotify and also preventing EG from saving it's configurations).
In w7 64 bit, a lot of problems with access rights is preventing previous working solutions from functioning...I do not know, maybe setting up user accounts somehow could solve the problems. You have to investigate if you can find a solution to the access rights problems, use a 32 bit environment or live with this limitation
BR
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
Re: Spotify
Is there anything in the code that runs on start that makes it work when spotify is already started?
or that runs in older windows when it notice spotify starts?
would it be possible to make that a eventghost function?
couse in that case maby a workaround is to add eventghost plugin proccess watcher, then when it notice spotify.exe start event it launches that function and the spotifyplugin "re-attatches" itself
or that runs in older windows when it notice spotify starts?
would it be possible to make that a eventghost function?
couse in that case maby a workaround is to add eventghost plugin proccess watcher, then when it notice spotify.exe start event it launches that function and the spotifyplugin "re-attatches" itself
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Spotify
I found the reason why it did not work unless Spotify was already started 
In w7, I think you have to run EG as admin anyway to have full control of the Spotify application
See first post for published version
In w7, I think you have to run EG as admin anyway to have full control of the Spotify application
See first post for published version
Last edited by krambriw on Mon Dec 30, 2013 1:20 pm, edited 1 time in total.
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
Re: Spotify
It seems to be working great now! Thank you so much.
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Spotify
See first post for published version
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
-
Silverhawk
- Posts: 16
- Joined: Sun Nov 10, 2013 6:19 pm
Re: Spotify
Using it a lot,t hanks for this krambriw! I use it to remotely control my spotify from my tablet/phone, with the events I can keep an updated notification on my phone/tablet as well with the current song that is playing.
One thing doesn't work properly though, next playlist/previous playlist/Last Playlist. When you are in the wrong selection it doesn't work. To get the selection into playlist three use ctrl+L (go to search bar), sleep, tab. Changed the code a bit in my plugin and it seems to work every time.
BTW: Is there any way you could add a command to get the playlist name?
My edited go to last playlist class:
One thing doesn't work properly though, next playlist/previous playlist/Last Playlist. When you are in the wrong selection it doesn't work. To get the selection into playlist three use ctrl+L (go to search bar), sleep, tab. Changed the code a bit in my plugin and it seems to work every time.
BTW: Is there any way you could add a command to get the playlist name?
My edited go to last playlist class:
Code: Select all
class GoToPlayList(eg.ActionClass):
name = "Go to playlists tree view and start playing the last one"
description = "Go to Playlist tree view and start playing"
def __call__(self):
sh = win32com.client.Dispatch("WScript.Shell")
win32api.Sleep(100)
if self.plugin.bSpotifyObjectCreated:
hWnd = win32gui.FindWindow("SpotifyMainWindow", None)
BringHwndToFront(hWnd)
win32api.Sleep(200)
sh.AppActivate("spotify")
win32api.Sleep(500)
sh.SendKeys("^l")
win32api.Sleep(100)
sh.SendKeys("{TAB}")
win32api.Sleep(100)
sh.SendKeys("{END}")
win32api.Sleep(100)
sh.SendKeys("{ENTER}")
del hWnd
del sh
return