Page 9 of 12

Re: Spotify

Posted: Sun Jan 05, 2014 3:09 pm
by krambriw
@Silverhawk,

Thanks a lot for your kind words and additions to the plugin. I will incorporate them in the next version.
Is there any way you could add a command to get the playlist name?
It's unfortunately not possible via the pytify api. Maybe could be achieved using the win32api or similar trying to find window titles but it would be messy. At least, I am not skilled enough to drill down that path. The whole playlist handling is in itself a mock-up made with win32 stuff tricks using sendkeys and I personally dislike it but it was at that time the only way.

There are more modern api's available today, also in python, but so far I have only seen them working fine under Linux. Also here, with those new api's. I have not updated myself of their capabilities.

Best regards, Walter

Re: Spotify

Posted: Fri Feb 07, 2014 5:33 am
by m19brandon
This is a follow up to a few post back about playing a known playlist.
In Spotify you can right-click > copy Spotify URI and use the URI command to open up a playlist.

First run the MySpotify.TerminateSpotify() action to insure Spotify is not running. For some reason Spotify will not change to a different playlist with the URI command if already open.

Then some Python:

Code: Select all

import time

#Start Spotify with an URI command and change to the playlist
#Playlist: 2014
eg.plugins.System.Execute(u'C:\\Users\\jon\\AppData\\Roaming\\Spotify\\spotify.exe', u'/uri spotify:user:########:playlist:dsds325mQNaTsh3E7traUApx', 0, False, 2, u'', False, False)

time.sleep(5)

#Loops through for a minute until Spotify has fully loading the playlist
# and then starts playing
cnt = 1
while (cnt < 61):
    p = eg.plugins.MySpotify.GetStatus()
    if p <> None:
        time.sleep(3) 
        print 'Spotify has started'
        if p.find('Not playing anything')<>-1:
            eg.plugins.MySpotify.Play()
            break
    else:
        print 'Spotify has not start/loaded fully yet, try ' + str(cnt)
    time.sleep(1) 
    cnt = cnt + 1
else:
    print 'Error, Spotify has not loads fully or did not launch.  Please review.'
Edit: my uri command was missing the word spotify

Re: Spotify

Posted: Tue Oct 14, 2014 2:24 am
by eirik226
Hello,

Thanks for the great plugin :)

However, I do have some problems and i'll try to explain them as well as I can.

1. When I use text 2 speech to find out what song is playing it works great, but in some songs, I have no idea why, it cuts part of the song title name. I don't think it does it with Artists, not that I have noticed anyway!

As you can see in the provided picture at one point I am listening to "The proclaimers - I'm on my way" when I read this with the text 2 speech it says "I'm on my W" nothing more. Do you know a fix?

Edit: It's really weird, it's only on some songs, and the name of the song has nothing to do with it. I randomly tried many songs now and also found out that it won't display "Abba - Mamma Mia" it displays "Abba - Mamma M" (To not hurt my reputation, this is all random songs, nothing that I keep on my playlist, eerrrr)

2. As you can see in the provided picture, when spotify is not playing anything and I press the button I have on my webserver to read what I am listening to out load it says "t playing anything" - not "NOt playing anything".

Image

I guess it's just something in the code, but I don't know how to fix it and I've tried to go over everything, but no programing expert.

Anyway, thanks in advance if you can help in this :)

Re: Spotify

Posted: Tue Oct 14, 2014 6:34 am
by krambriw
Hello eirik226,

May I give you a suggestion?

Instead of the Speech plugin, use the new IntelliSpeech plugin just recently released by Pako. It will give you a much better sound experience!!

I would configure the setup like below

1)Add the IntelliSpeech plugin, you may set the languages as you wish but I selected English/English

2)Add a macro with a python script and Copy & paste the script sample from below

Code: Select all

#08:11:14   MySpotify.CurrentArtistTrack ['Nina Persson', 'Clip Your Wings']
#08:22:36   MySpotify.CurrentArtistTrack ['Not playing anything...', '']

pl = eg.event.payload
artist = pl[0]
track = pl[1]
if artist == 'Not playing anything...':
    eg.plugins.IntelliSpeech.Speak(u'English', u'Not playing anything...', 100)    
else:
    eg.plugins.IntelliSpeech.Speak(u'English', u'Now playing'+artist+' - '+track, 100)
3)Drag and drop the event to macro as in the picture below
Image1.jpg
Image1.jpg (5.04 KiB) Viewed 6477 times
Now it should work when you play or stop playing. You can now easily modify the script with whatever spoken message you like to use.

Best regards, Walter

Re: Spotify

Posted: Tue Oct 14, 2014 1:16 pm
by eirik226
Hello,

Awesome and thanks for all your help :) I'll give it a try later when I am done with work and post the results - I guess it'll work! :)

Re: Spotify

Posted: Thu Oct 23, 2014 9:03 pm
by eirik226
Hey again!

I'm sorry but I can't get it to work. I've tried for a few days but I don't really know how to code that well so I didn't get anywhere.
Anyone, I get the following error message when I try to run the script:

Code: Select all

         Traceback (most recent call last):
           Python script "13", line 6, in <module>
             track = pl[1]
         IndexError: list index out of range
My guess is that the eg.event.getpayload or what it's called does not get any information? I don't know, that could also be 100% wrong.

Do you know what could be wrong?

Re: Spotify

Posted: Fri Oct 24, 2014 3:38 am
by krambriw
You have to describe your configuration better. Like I did. With screenshots how you have configured your macro, the code of your python script (the formatting is very sensitive in python).

Helping you otherwise is like stumbling in the dark.

Re: Spotify

Posted: Sat Oct 25, 2014 12:15 pm
by bobbano
Hello Krambriw

I just found this plugin via the AutoRemote Google+ community and it looks promising :)

However, I can't seem to get the Start Spotify to work. All I get is "invalid directory" (can't remember the exact phrase right now).
I checked in the __init.py__ file and found a reference to the executable, which was incorrect. C:\users\username etc.
I changed what I believe was your username to mine and there was also double backslashes between all folders which I kept.

But it still won't work. The other actions (at least those I've tried) work when Spotify is running but I want to be able to start it as well :)

I'm running Windows 7 ultimate x64 and I've tried running EG both with and without admin rights.

Any clues? Let me know if you need more info.

Re: Spotify

Posted: Sat Oct 25, 2014 1:20 pm
by krambriw
Yes, this is a known problem that I haven't solved yet. Somewhere in this thread there is a description how you have to modify the path tp Spotify in the python code when running win 7 and later

Re: Spotify

Posted: Sat Oct 25, 2014 7:52 pm
by bobbano
Shame on me :oops:

I did modify the path so it was correct, but I didn't notice that it was commented out (the # in the beginning of the line).

Now it works :)

Re: Spotify

Posted: Wed Nov 12, 2014 1:44 pm
by z3us
Hi. Thanks for the plugin.
- Is it possible to do a like/dislike to a song of my radio through EVG?
- Is it possible to import the cover?


Thanks again!!

Re: Spotify

Posted: Wed Nov 12, 2014 3:57 pm
by krambriw
No, sorry, not possible
I have a suggestion, check out the Mopidy plugin that I wrote recently. Mopidy can control Spotify much better I think

Re: Spotify

Posted: Wed Nov 12, 2014 10:30 pm
by sveflo
Hi! Great plugin!

I was wondering if anyone know how to send the EG info log over TCP/IP-Telnet to for example a Control System ?

When i execute the spotify command "Get current song title" there pops up a "info" with the track info in eventghost log, this is the text i want to send over Telnet.

In advance, thanks for any help regarding this

Re: Spotify

Posted: Thu Nov 13, 2014 7:48 am
by krambriw
This requirement has been foreseen and is supported. You just create a python script that you can trigger:

Code: Select all

res = eg.plugins.MySpotify.GetCurrentTrack()
#Now you have the current track info in the variable res
print res
#Add code to send res to your control system...
However, I would do it a bit different. Every time Spotify chages track, you will get an event in EG log. Typically like this;

Code: Select all

08:44:46   MySpotify.CurrentArtistTrack ['Lana Del Rey', 'Summertime Sadness']
If you create a macro and let this event trigger it, you could use the following python script (added to your macro) to send the information further

Code: Select all

pl = eg.event.payload
artist = pl[0]
track = pl[1]
#Add code to send artist/track to your control system...

Re: Spotify

Posted: Thu Nov 13, 2014 9:27 pm
by sveflo
Thank you very much for the reply!

Im a bit new to this, so the next question is how to send it, preferably by telnet, is this an already implemented plugin in EG or is there a script for that too?

In advance
Thanks again : :)