Kodi Community Forum
Beta Spotify for Kodi - Printable Version

Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Music Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=148)
---- Thread: Beta Spotify for Kodi (/showthread.php?tid=265356)



RE: Spotify for Kodi - marcelveldt - 2016-12-23

(2016-12-23, 15:41)sakos Wrote: What about the frequency? How often shall this procedure to be done?

Only once, it's needed for the oauth authentication where you grant the plugin access to your spotify data.
After that, the plugin can request a refresh token on it's own without the need for a webbrowser.

Offcourse, if you login to the spotify webpage-accountdetails and you delete the app permissions you'll have to do it again.


RE: Spotify for Kodi - jcjdammers - 2016-12-24

Hi,
I am using LibreELEC 7.0.2. and the Spotify addon is not able to logon and it times out after a few minutes. I am using my facebook account.
I have copied the log below.
What am I doing wrong? Any help is much appreciated.
Thanks,
Jeroen

10:19:00 T:140010347026176 NOTICE: Spotify --> Your platform (x86_64 System.Platform.Linux)
10:19:01 T:140010347026176 NOTICE: Spotify --> Starting background service...
10:19:01 T:140010347026176 NOTICE: Spotify --> Checking remembered_user ..
10:19:01 T:140010347026176 NOTICE: Spotify --> Cached session found
10:19:01 T:140009407502080 NOTICE: Spotify --> logged in: 0
10:19:06 T:140010347026176 NOTICE: Spotify --> starting proxy at port 8090
10:19:06 T:140010347026176 NOTICE: Spotify --> Setting callback ..
10:19:06 T:140010347026176 NOTICE: Spotify --> Obtaining user token ..
10:19:06 T:140010347026176 NOTICE: Spotify --> Encoding header ..
10:19:06 T:140011739522816 ERROR: warning:couldn't read token from cache
10:19:06 T:140011739522816 NOTICE: Spotify --> WebService - start helper webservice on port 52308
10:19:07 T:140011739522816 NOTICE: Spotify --> Waiting for authentication token...
10:20:00 T:140010363811584 NOTICE: Previous line repeats 53 times.
10:20:00 T:140010363811584 NOTICE: ES: Client from 127.0.0.1 timed out
10:20:01 T:140011739522816 NOTICE: Spotify --> Waiting for authentication token...
10:21:08 T:140011739522816 NOTICE: Previous line repeats 66 times.
10:21:08 T:140011739522816 NOTICE: Spotify --> WebService - stop called
10:21:08 T:140009306789632 ERROR: 127.0.0.1 - - [24/Dec/2016 10:21:08] "QUIT / HTTP/1.1" 200 -
10:21:08 T:140011739522816 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <class 'spotipy.oauth2.SpotifyOauthError'>
Error Contents: Bad Request
Traceback (most recent call last):
File "/storage/.kodi/addons/plugin.audio.spotify/plugin.py", line 3, in <module>
Main().main()
File "/storage/.kodi/addons/plugin.audio.spotify/resources/plugincontent.py", line 1146, in main
if self.checkLoginDetails():
File "/storage/.kodi/addons/plugin.audio.spotify/resources/plugincontent.py", line 1074, in checkLoginDetails
self.token = util.prompt_for_user_token(username)
File "/storage/.kodi/addons/plugin.audio.spotify/resources/libs/spotipy/util.py", line 59, in prompt_for_user_token
token_info = sp_oauth.get_access_token(code)
File "/storage/.kodi/addons/plugin.audio.spotify/resources/libs/spotipy/oauth2.py", line 213, in get_access_token
raise SpotifyOauthError(response.reason)
SpotifyOauthError: Bad Request
-->End of Python script error report<--
10:21:08 T:140011925334080 ERROR: GetDirectory - Error getting plugin://plugin.audio.spotify/
10:21:08 T:140011925334080 ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin.audio.spotify/) failed


RE: Spotify for Kodi - jcjdammers - 2016-12-24

I also installed Chromium browser. When I start Spotify then it launches Chromium with some long URL of Spotify, but the Chromium window stays empty, nothing is shown.


RE: Spotify for Kodi - Mr486 - 2016-12-24

I'm one step behind and have not managed to install the chromium browser yet


RE: Spotify for Kodi - sakos - 2016-12-25

(2016-12-23, 15:45)marcelveldt Wrote:
(2016-12-23, 15:41)sakos Wrote: What about the frequency? How often shall this procedure to be done?

Only once, it's needed for the oauth authentication where you grant the plugin access to your spotify data.
After that, the plugin can request a refresh token on it's own without the need for a webbrowser.

Offcourse, if you login to the spotify webpage-accountdetails and you delete the app permissions you'll have to do it again.
Great! Thank you.


RE: Spotify for Kodi - klaymen - 2016-12-26

Hi,

I just found this thread and wonder if the plugin might be a solution for my problem. I did not try it out yet and hope, somebody of you can tell me if this is the one to look into further, or maybe another plugin could do the job, or none at all. I hope it is OK to ask this before actually investing too much time, just to finally figure it's the wrong solution ...

I'm currently running Kodi on a Raspberry Pi3, using the OSMC distribution (I think it's near enough to OpenElec, not so sure about the fine details though). In addition, I'm running FHEM on the Pi, a Perl based open source home automation software (I'm not sure if it is ok to post foreign links here, you can just google for "fhem wiki" - it is in German though). This allows me to combine different wireless home automation systems (in my case Homematic on 868MHz and FS20 on 433MHz), my Logitech Harmony remote control, and Kodi. One thing I made and like a lot is a wall button (using FS20) that automatically turns on my receiver, switches its audio input to the PI3, starts a Spotify plugin on Kodi, and plays one of my playlists (using my Spotify Premium account). After it's started, the same button can be used to switch to the next track (context sensitive programming).

Currently I'm using the Spotimc plugin for this purpose - the only one usable enough at the time when I set this up. It actually works - the only problem is that Spotimc does not give you direct access to certain functions, like playing a certain playlist. I think this has to do with the old library instead of the api. What would be required is a direct, xml or json based access to these functions. My current implementation code for above mention button using Spotimc under FHEM is

Code:
Button1r.on {
  if (ReadingsVal("kodi","playStatus","") eq "playing") # if already playing, work as switch-to-next-track
  {
    fhem("set kodi next");
  } else
  {
    fhem('set hub activity Streaming'); # Logitech Harmony is set to teh Streaming activity
    fhem('set kodi addon script.audio.spotimc "" ""');  # Start plugin and wait until it probably is initialized
    sleep(13);
    fhem("set kodi up");       # Navigate  to playlist tab and select, then wait 3 seconds
    fhem("set kodi right");
    fhem("set kodi select");
    sleep(3);
    fhem("set kodi down");  # Select playlist and wait 2 seconds
    fhem("set kodi down");
    fhem("set kodi down");
    fhem("set kodi down");
    fhem("set kodi down");
    fhem("set kodi down");
    fhem("set kodi right");
    fhem("set kodi select");
    sleep(2);
    fhem("set kodi select");  # start playlist and wait to seconds
    sleep(2);
    fhem("set kodi next");    # Switch to next track (random shuffling) to avoid always starting with the first track
  }
}

As you can see, this is basically constructed upon navigating around in the Spotify user interface and knowing where things are (playlist tab, relative location of the playlist in question, etc). No Spotify funtion is used directly, everything is done using Kodi instructions. Also,time delays need to be added to make sure nothing is lost - eg, the 13 seconds to make sure Spotimc actually is listening to navigation commands. Such a construction is of course suboptimal - sometimes navigation commands are lost (rarely though, as it is over LAN and not just infrared), sometimes the playlist arrangement changes and the wrong one is selected, etc. So, I look for a replacement that allows me to send direct commands. To my understanding, the main issue is Spotify itself not wanting the community to use such interfaces, in order to hinder the development of open source developments, but I'm not sure if this really is the case. Anyway, would this - or some other - plugin be a better solution for my problem?

Thanks in advance,

Andy


RE: Spotify for Kodi - boss92500 - 2016-12-27

Hi,

I installed spotify 1.0.25 on PI3 and gave spotify premium login.
Impossible to launch the application.
Some help welcome !


RE: Spotify for Kodi - kelemenlajos - 2016-12-27

(2016-11-23, 01:25)mgkday Wrote:
(2016-11-21, 11:13)SKUK Wrote: Thanks for this great addon.

I copied the cache file in the following directory:
/storage/.kodi/userdata/addon_data/plugin.audio.spotify.



Hi SKUK, can you please describe the steps you did to make it work ? I tried many times reinstalling the plugin, then copying back the files, with no success, still get the same errors...

Did you manage to start this spotify?
I went trough all of your steps, and had the same problems Smile


RE: Spotify for Kodi - Bierlag - 2016-12-27

Hi guys, sorry to ask this but it's driving me crazy,

Is there a way to search in Spotify from the Web interface?

Image

I'm using the search option, but nothing happens.

I've tried several web browsers but no joy.


RE: Spotify for Kodi - klaymen - 2016-12-27

Hi guys,

I now gave it a try, but I'm having problems installing it on my Raspberry using Kodi (osmc with confluence skin).

I did additionally install the plugin under Windows, where it works, and copied over the xyz.cache file to ~/.kodi/userdata/addon_data/plugin.audio.spotify/xyz.cache. But I think my problem starts earlier...

One thing I noticed there - not sure if it is relevant - is that the corresponding directory in Windows has an additional libspotify folder, which is not there in the raspberry version. But I suspect this directory is not created until a successful login occurs (not sure though, I thought I mention it). The settings.xml is identical on Windows and the Raspberry, and of course the cache file too.

When I start the plugin, it just says "Working" for some time, and then returns a "Login Error" (but of course the password is correct, I see it in settings.xml, and it works in the windows version). I enabled debug logging, and that's the output I get:

Code:
21:29:00 366.946259 T:1956275120   DEBUG: CGUIMediaWindow::GetDirectory (plugin://plugin.audio.spotify/)
21:29:00 366.946472 T:1956275120   DEBUG:   ParentPath = [addons://sources/audio/]
21:29:00 366.948914 T:1565504496   DEBUG: StartScript - calling plugin Spotify('plugin://plugin.audio.spotify/','1','')
21:29:00 366.949371 T:1506800624   DEBUG: Thread LanguageInvoker start, auto delete: false
21:29:00 366.950256 T:1565504496   DEBUG: WaitOnScriptResult - waiting on the Spotify (id=5) plugin...
21:29:00 366.950592 T:1506800624    INFO: initializing python engine.
21:29:00 366.950958 T:1506800624   DEBUG: CPythonInvoker(5, /home/osmc/.kodi/addons/plugin.audio.spotify/plugin.py): start processing
21:29:01 367.264618 T:1506800624   DEBUG: -->Python Interpreter Initialized<--
21:29:01 367.265198 T:1506800624   DEBUG: CPythonInvoker(5, /home/osmc/.kodi/addons/plugin.audio.spotify/plugin.py): the source file to load is "/home/osmc/.kodi/addons/plugin.audio.spotify/plugin.py"
21:29:01 367.266235 T:1506800624   DEBUG: CPythonInvoker(5, /home/osmc/.kodi/addons/plugin.audio.spotify/plugin.py): setting the Python path to /home/osmc/.kodi/addons/plugin.audio.spotify:/home/osmc/.kodi/addons/script.module.requests/lib:/home/osmc/.kodi/addons/script.module.six/lib:/usr/share/kodi/addons/script.module.simplejson/lib:/usr/share/kodi/addons/script.module.unidecode/lib:/usr/lib/python2.7:/usr/lib/python2.7/plat-arm-linux-gnueabihf:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/PILcompat:/usr/lib/python2.7/dist-packages/gtk-2.0:/usr/lib/pymodules/python2.7
21:29:01 367.266541 T:1506800624   DEBUG: CPythonInvoker(5, /home/osmc/.kodi/addons/plugin.audio.spotify/plugin.py): entering source directory /home/osmc/.kodi/addons/plugin.audio.spotify
21:29:01 367.266815 T:1506800624   DEBUG: CPythonInvoker(5, /home/osmc/.kodi/addons/plugin.audio.spotify/plugin.py): instantiating addon using automatically obtained id of "plugin.audio.spotify" dependent on version 2.1.0 of the xbmc.python api
21:29:01 367.448547 T:1956275120   DEBUG: ------ Window Init (DialogBusy.xml) ------
21:29:03 369.264832 T:1506800624   DEBUG: Spotify --> waiting for service...
21:29:03 369.274445 T:1536885744   DEBUG: Thread LanguageInvoker start, auto delete: false
21:29:03 369.274750 T:1536885744    INFO: initializing python engine.
21:29:03 369.274872 T:1536885744   DEBUG: CPythonInvoker(6, /home/osmc/.kodi/addons/plugin.audio.spotify/spotifyservice.py): start processing
21:29:03 369.571014 T:1536885744   DEBUG: -->Python Interpreter Initialized<--
21:29:03 369.571381 T:1536885744   DEBUG: CPythonInvoker(6, /home/osmc/.kodi/addons/plugin.audio.spotify/spotifyservice.py): the source file to load is "/home/osmc/.kodi/addons/plugin.audio.spotify/spotifyservice.py"
21:29:03 369.572327 T:1536885744   DEBUG: CPythonInvoker(6, /home/osmc/.kodi/addons/plugin.audio.spotify/spotifyservice.py): setting the Python path to /home/osmc/.kodi/addons/plugin.audio.spotify:/home/osmc/.kodi/addons/script.module.requests/lib:/home/osmc/.kodi/addons/script.module.six/lib:/usr/share/kodi/addons/script.module.simplejson/lib:/usr/share/kodi/addons/script.module.unidecode/lib:/usr/lib/python2.7:/usr/lib/python2.7/plat-arm-linux-gnueabihf:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/PILcompat:/usr/lib/python2.7/dist-packages/gtk-2.0:/usr/lib/pymodules/python2.7
21:29:03 369.572510 T:1536885744   DEBUG: CPythonInvoker(6, /home/osmc/.kodi/addons/plugin.audio.spotify/spotifyservice.py): entering source directory /home/osmc/.kodi/addons/plugin.audio.spotify
21:29:03 369.572693 T:1536885744   DEBUG: CPythonInvoker(6, /home/osmc/.kodi/addons/plugin.audio.spotify/spotifyservice.py): instantiating addon using automatically obtained id of "plugin.audio.spotify" dependent on version 2.1.0 of the xbmc.python api
21:29:04 370.440186 T:1506800624   DEBUG: Spotify --> waiting for service...
21:29:04 370.578491 T:1536885744  NOTICE: Spotify --> Your platform (armv7 System.Platform.Linux)
21:29:04 371.072784 T:1536885744   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.ImportError'>
                                            Error Contents: cannot import name MainLoop
                                            Traceback (most recent call last):
                                              File "/home/osmc/.kodi/addons/plugin.audio.spotify/spotifyservice.py", line 3, in <module>
                                                import resources.playbackservice as service
                                              File "/home/osmc/.kodi/addons/plugin.audio.spotify/resources/playbackservice.py", line 11, in <module>
                                                from spotify import MainLoop, ConnectionState, ErrorType, Bitrate, link
                                            ImportError: cannot import name MainLoop
                                            -->End of Python script error report<--
21:29:04 371.074036 T:1956275120   DEBUG: ------ Window Init (DialogKaiToast.xml) ------
21:29:04 371.243042 T:1536885744    INFO: Python script stopped
21:29:04 371.243256 T:1536885744   DEBUG: Thread LanguageInvoker 1536885744 terminating
21:29:05 371.441132 T:1506800624   DEBUG: Spotify --> waiting for service...
21:29:10 376.463623 T:1956275120   DEBUG: Previous line repeats 5 times.
21:29:10 376.463806 T:1956275120   DEBUG: ------ Window Deinit (DialogKaiToast.xml) ------
21:29:11 377.443024 T:1506800624   DEBUG: Spotify --> waiting for service...
21:29:18 384.581482 T:1793315824   DEBUG: Previous line repeats 7 times.
21:29:18 384.581757 T:1793315824   DEBUG: script.module.osmcsetting.updates :  - blurp 230 - DialogBusy.xml
21:29:19 385.448730 T:1506800624   DEBUG: Spotify --> waiting for service...
21:29:28 394.331543 T:1956275120   DEBUG: Previous line repeats 8 times.
21:29:28 394.331909 T:1956275120   DEBUG: SECTION:UnloadDelayed(DLL: special://xbmcbin/system/ImageLib-arm.so)
21:29:28 394.453918 T:1506800624   DEBUG: Spotify --> waiting for service...
21:29:30 396.949585 T:1713370096   DEBUG: Previous line repeats 2 times.
21:29:30 396.949982 T:1713370096   DEBUG: Thread JobWorker 1713370096 terminating (autodelete)
21:29:31 397.459320 T:1506800624   DEBUG: Spotify --> waiting for service...
21:29:53 419.477203 T:1506800624   DEBUG: Previous line repeats 22 times.
21:29:53 419.477844 T:1506800624   DEBUG: POParser: loaded 34 strings from file /home/osmc/.kodi/addons/plugin.audio.spotify/resources/language/English/strings.po
21:29:53 419.487396 T:1956275120   DEBUG: ------ Window Init (DialogOK.xml) ------
21:29:53 419.487579 T:1956275120    INFO: Loading skin file: DialogOK.xml, load type: KEEP_IN_MEMORY
21:30:06 432.919556 T:1956275120   DEBUG: ------ Window Deinit (DialogOK.xml) ------
21:30:06 432.930664 T:1565504496   DEBUG: WaitOnScriptResult- plugin returned successfully
21:30:06 432.930908 T:1506800624    INFO: CPythonInvoker(5, /home/osmc/.kodi/addons/plugin.audio.spotify/plugin.py): script successfully run

It seems the "from spotify import MainLoop, ConnectionState, ErrorType, Bitrate, link" line in playbackservice.py does not work... I actually tried a "sudo find / -name spotify.py -print", and it does not return anything. This python file does not seem to be present on my system.... I do have a /usr/local/lib/python2.7/dist-packages/spotify/ directory though, "pip install pyspotify" does not fix the problem (it says it's already present). Here an interactive output:

Code:
>>> from spotify import ConnectionState, ErrorType, Bitrate, link
>>> from spotify import MainLoop
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name MainLoop
>>>

Actually even on my Mac (without anything else installed), when I do a "pip install pyspotify", it is installed, but a manual import check like above gives exactly the same result. Also, spotify.__dict__ does not contain MainLoop... I think I'm missing something trivial - maybe a dependency?

Thanks, Andy


RE: Spotify for Kodi - mgkday - 2016-12-28

Andy, let us know of the evolution of your issue, I am interested as I've been blocked on the (almost) same stage for days now (look at previous pages) and you went even further as you got the "working" at least !


RE: Spotify for Kodi - marcelveldt - 2016-12-28

I have placed version 1.0.26 on my beta repo which should fix some of the login issues that were reported.

Please remember the following notes regarding the addon:

1) There must be a webbrowser installed for the authentication prompt. (or use the workaround from the first post)
2) No support for Android armv8 or Android x86 platform
3) No support for MacOS Sierra

It's still waiting for Spotify to deliver a substitute for the old libspotify so we can have proper playback support on modern platforms.


RE: Spotify for Kodi - marcelveldt - 2016-12-28

(2016-12-27, 16:07)Bierlag Wrote: Hi guys, sorry to ask this but it's driving me crazy,
Is there a way to search in Spotify from the Web interface?

No, as far as I'm aware not as the search command in the plugin opens the keyboard dialog in Kodi.


RE: Spotify for Kodi - klaymen - 2016-12-28

Addendum: I also tried installing Kodi and the Spotfy plugin under MacOS (version 10.11.6, El Capitan). Here the start of the plugin crashes Kodi, immediately after entering username and password, the plugin.audio.spotify directory is not created at all. If I create the directory manually (~/Library/Application Support/Kodi/userdata/addon_data/plugin.audio.spotify) and copy over the files from Windows, it still crashes, but does not ask username and password (so it does find the settings.xml at least). Can't be a privilege issue, all files are owned by me, not root or so. In the debug log, the last I see is

Code:
11:52:18.275 T:123145312116736   DEBUG: CPythonInvoker(2, /Users/xxx/Library/Application Support/Kodi/addons/plugin.audio.spotify/spotifyservice.py): entering source directory /Users/xxx/Library/Application Support/Kodi/addons/plugin.audio.spotify
11:52:18.275 T:123145312116736   DEBUG: CPythonInvoker(2, /Users/xxx/Library/Application Support/Kodi/addons/plugin.audio.spotify/spotifyservice.py): instantiating addon using automatically obtained id of "plugin.audio.spotify" dependent on version 2.1.0 of the xbmc.python api
11:52:18.349 T:123145312116736  NOTICE: Spotify --> Your platform (x86_64 System.Platform.OSX)
11:52:18.579 T:123145312116736  NOTICE: Spotify --> Starting background service...

I also got a crash report, but not anymore (it seems these reports are not displayed anymore after 3 or so repetitions), so I can't paste it here. It would also be quite long.

I'm not needing Kodi on Mac - I just thought it might help me solving the Python issue above, but thought I mention it here anyway.


RE: Spotify for Kodi - klaymen - 2016-12-28

(2016-12-28, 12:53)marcelveldt Wrote: I have placed version 1.0.26 on my beta repo which should fix some of the login issues that were reported.

Hmm I'm not yet too familiar with the Kodi interface I guess, but I only see version 1.0.25? I did check the emby beta (1.0.5) as well as your private one (1.0.1) - not sure which one you mean with "my beta repo" :-) But both still seem to have 1.0.25, do I need to initiate some kind of cache reload? I even tried removing the 1.0.25 and re-installing, still I see no 1.0.26... Well I'll check again later, maybe it needs some time to update mirrors or so.