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.

Spotify (api is partially broken)

Questions and comments specific to a particular plugin should go here.
Jostein
Experienced User
Posts: 108
Joined: Sun Feb 15, 2009 12:59 pm

Re: Plugin for Spotify

Post by Jostein »

Hi krambriw.

Have done some testing now. Like the new comands alot. and alsow now the: "Spotify Window was not found" is not all over the log window. It sems the bug is still there, where you able to reproduse it or is it just me that get it? Anyway the bug is not bothering me as i now have no need for deactivating the plugin anymore.

I have one more sugjestion. First of it is nothing i have a need for and maby nobody has, this would be something you would have to deside. Instead of having the print statment "Spotify Window was not found" make an event "Spotify Window was not found". That way if people want they can create a macro launching spotify.

I replaced the line 145

Code: Select all

print self.text.infoNoWindow
with this:

Code: Select all

self.TriggerEvent("Spotify Window was not found")
Then i use the event to launch spotify and Minimize it to the tray.

Maby if you like the idea this could be an optional function from the config of the plugin.
*********************************
Edit.
Sems i was a bit to quick with that sugjestion. Now after removing the plugin and adding it again i dont get the fault "Spotify Window was not found" on startup anymore. Sorry.


Best regards Jostein
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Plugin for Spotify

Post by krambriw »

Hi, good testing, thanks!

Can you give me some input on how the various scenarios should be? Changing from prints to events is very easy as you showed

This is how it works today

1. Startup
If Spotify is not found running, you will get a print in the log every 10 seconds. When Spotify is found running, the prints does not appear any more
To change to event is easy but I assume that you only want one (non-repetitive)?

2. Spotify is closed from "outside" of EG
If Spotify is closed directly, the same will happen as above

3. Spotify is closed from "inside" EG
If Spotify is closed using the "Terminate" Action no events or prints are created because in this case it is a planned action and has most likely a good reason that EG controls


Best regards, Walter

PS I can't recreate the bug you are mentioning
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Plugin for Spotify

Post by krambriw »

Hello Spotify users,

The last couple of hours, I have elaborated a bit with WSH (Windows Scripting Host) and tried to use it with Sendkeys from python.

Reason was because the "api" to Spotify is missing some vital functions like select & play a playlist etc. I therefore thought I should give it a try to use Sendkeys function in order to control those functions instead

Attached is a new version that implements som new actions for this purpose:
- Go to playlists tree view
- Select next playlist
- Select previous playlist
- Show and start playing

I also changed the printout "Spotify Window was not found" to an event instead

To install: always easiest to re-do your configuration and let the plug-in build your configuration tree. Otherwise you can just add the new actions manually once you have replaced the files and restarted eg

Right now I have added some remote button events to the actions and I can (with the remote) step up/down and play my playlists!!!

Tomorrow I'm heading to the shop for a RF remote I just found. See picture below
RF_remote.jpg
RF_remote.jpg (7.22 KiB) Viewed 9534 times
Spotify.zip
(5.78 KiB) Downloaded 374 times

Best regards, Walter
Jostein
Experienced User
Posts: 108
Joined: Sun Feb 15, 2009 12:59 pm

Re: Plugin for Spotify

Post by Jostein »

Hi krambriw.

This is great mutch beter than emulating keypreses like i had to do before.

I am not so sure on how the functioning should be for it but i like it alot the way it is now with event instead of the message that way if it is not found it starts up by itself. Maby other people dont like it that way. Could maby make it so that you can chose between message, event and nothing as plugin configuration. Anybody else have any idea of what you would want?

Alsow do you now how to past the now playing to an "on screen message" or a "speak comand" what would i need to write in the text/say field?


Best Regards
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Plugin for Spotify

Post by krambriw »

Just an update: I have tried to improve the reliability when using SendKeys. Earlier version could miss some commands sometimes. I think this works better
__init__.py
(15.85 KiB) Downloaded 445 times
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Plugin for Spotify

Post by krambriw »

EventGhost 0.4.0 update

I have updated the plugin with the mandatory GUID entry
Last edited by krambriw on Tue Dec 22, 2009 6:06 am, edited 1 time in total.
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Plugin for Spotify

Post by krambriw »

Alsow do you now how to past the now playing to an "on screen message" or a "speak comand" what would i need to write in the text/say field?
One way you can do it is like this:

1) Add the "Speech" plugin to your configuration

Edit the Spotify plugin and replace the following code for the action class "Get Status"
Every time you trigger the macro, you will get an OSD as well as a spoken message for "Now playing"

Code: Select all

class GetStatus(eg.ActionClass):
    name = "Get current Status"
    description = "Gets the Status of Spotify."


    def __call__(self):
        if self.plugin.bSpotifyObjectCreated:
    		if self.plugin.spotify.isPlaying():
    			nowplaying = (
    			    "Now playing " 
    			    + self.plugin.spotify.getCurrentArtist() 
    			    + " - " 
    			    + self.plugin.spotify.getCurrentTrack()
    			)
    		else:
    			nowplaying = "Not playing anything..."
    		print "Spotify running! " + nowplaying
    		
    		eg.plugins.Speech.TextToSpeech(
    		    u'Microsoft Anna - English (United States)',
    		    0,
    		    nowplaying,
    		    0,
    		    100
    		)

	        eg.plugins.EventGhost.ShowOSD(
	            nowplaying,
	            u'0;-24;0;0;0;700;0;0;0;1;0;0;2;32;Arial',
	            (255, 255, 255),
	            (0, 0, 0),
	            0,
	            (0, 0),
	            0,
	            5.0,
	            False
	        )
    		return "Spotify running! " + nowplaying
        else:
            print self.plugin.text.infoStatus
	
Jostein
Experienced User
Posts: 108
Joined: Sun Feb 15, 2009 12:59 pm

Re: Plugin for Spotify

Post by Jostein »

hi krambriw.

Thanks for the replay.

This would work all the time. But what i want is the ability to get the print statments into for exampel the "web server" or into the "OSD" or the "speak" plugin is there not some smal phyton script i can run without enterupting with the plugin. That way i can have the computer pause the track and say what is playing if i press a sertan key. I use spotify in rooms without any screen only speakers with a RF remote:
http://cgi.ebay.com/ws/eBayISAPI.dll?Vi ... K:MEWNX:IT

Is there some code to get the latest printed statment like for example: "eg.global.latestprint"

Best regards Jostein
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Plugin for Spotify

Post by krambriw »

Hi,
I see...
Maybe there is a way. Otherwise we need to change the print to an event and capture/filter those with a small script that runs in a loop and when it finds "Now playing" it will send the content to the speech/osd

Best regards, Walter
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Spotify

Post by krambriw »

Hello Jostein,

Actually, I found a very simple and obvious way to get the information "Get Current Status" from a script as the example below shows. Put the script in a macro together with the key press event you prefer and it should work ;)

With the data available in the script, you can use python to bring it into virtually anything you have configured in your system

Best regards, Walter

Code: Select all


nowplaying = eg.plugins.MySpotify.GetStatus()
nowplaying = nowplaying.split('!')
n = nowplaying[1]

eg.plugins.Speech.TextToSpeech(
    u'Microsoft Anna - English (United States)',
    0,
    n,
    0,
    100
)

eg.plugins.EventGhost.ShowOSD(
    n,
    u'0;-24;0;0;0;700;0;0;0;1;0;0;2;32;Arial',
    (255, 255, 255),
    (0, 0, 0),
    0,
    (0, 0),
    0,
    8.0,
    False
)
Jostein
Experienced User
Posts: 108
Joined: Sun Feb 15, 2009 12:59 pm

Re: Spotify

Post by Jostein »

Hi krambriw.

Yes this is the way i wanted to do it. Thanks that works great.

I tried also to use the split comand to remove the now playing. But i did not get it working. I gues i have to find some time to read a phyton scripting book or two.


Best regards Jostein
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Spotify

Post by krambriw »

:D

Code: Select all


nowplaying = eg.plugins.MySpotify.GetStatus()
nowplaying = nowplaying.split('!')
n = nowplaying[1]
p = n.strip("Now playing ")



eg.plugins.Speech.TextToSpeech(
    u'Microsoft Anna - English (United States)',
    0,
    p,
    0,
    100
)

eg.plugins.EventGhost.ShowOSD(
    p,
    u'0;-24;0;0;0;700;0;0;0;1;0;0;2;32;Arial',
    (255, 255, 255),
    (0, 0, 0),
    0,
    (0, 0),
    0,
    8.0,
    False
)
Jostein
Experienced User
Posts: 108
Joined: Sun Feb 15, 2009 12:59 pm

Re: Spotify

Post by Jostein »

Hehe that was fast.

Thanks.

Best regards Jostein
daniel.n
Posts: 8
Joined: Sun Dec 20, 2009 11:05 pm

Re: Spotify

Post by daniel.n »

Walter, damn, you're a hard working guy! Thanks for your efforts, writing this plugin and others, and being helpful.

I will need and use this shortly. I bought an Apple Airport Express and have been using it kind of nonstop as an endpoint for Spotify audio from a netbook (Airfoil!!). It works great, the netbook is a fairly awesome Spotify remote. But battery life is a problem, and I see myself wanting to have spotify audio in the garage in the future. This presents a few potential scenarios where controlling a Spotify instance from my (yet to be bought) iPhone will be very convenient. Writing a small webpage for the default webserver plugin that'll do the trick will very easy, thanks to this plugin!
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Spotify

Post by krambriw »

Hi,
In the latest version (look in the beginning of this thread) I have added an action that can be used to start Spotify

Best regards, Walter
Post Reply