Kodi Community Forum
[WIP] XBMC + Spotify = True (an XBMC implementation that uses Spotify's official API) - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Discussions (https://forum.kodi.tv/forumdisplay.php?fid=222)
+--- Forum: Kodi related discussions (https://forum.kodi.tv/forumdisplay.php?fid=6)
+--- Thread: [WIP] XBMC + Spotify = True (an XBMC implementation that uses Spotify's official API) (/showthread.php?tid=67012)



- akezeke - 2010-11-16

Glad you got it working, regarding the playlist crash it might be because of offline files, I have not implemented any handling for those since that feature appeared after spotyxbmc was written. I will look into it someday.


- momoski - 2010-11-16

Another thing that causes a crash. When searching for an artist. When clicking on the artist, the albums are supposed to be displayed. Instead you see Browsing albums for a few seconds. This is the case for both artists with a lot of albums and not so many albums. Might be the same thing that goes wrong with the playlists.

Quote:NOTICE: Spotifylog: 22:44:08.373 I [file_streamer_simple.cpp:753] Request for file ebf6e4066694079f87112b6f9d7402af6ea3b6b0 complete (code: 0)
ERROR: XLCDproc::Initialize - Unable to connect to host. Giving up.

and another line found, which I think is the one that causes the trouble. Maybe this can help:
Quote:DEBUG: DialogProgress::StartModal called
DEBUG: ------ Window Init (DialogProgress.xml) ------
DEBUG: Alloc resources: 0.30ms (0.01 ms skin load)
ERROR: GetDirectory - Error getting musicdb://spotify/command/newsearch/
ERROR: CGUIMediaWindow::GetDirectory(musicdb://spotify/command/newsearch/) failed

Searching for a track goes OK.


- Puffytroll - 2010-11-16

Thanks for the help everyone! I will try to compile tomorow. If it fails this time, I just wait until a stable version is released, and uses a normal spotify client via the Executor plugin :p

If beta testers or anything like that is needed, I will be glad to help! Wink


- akezeke - 2010-11-16

@momoski

If you are using 0.0.3 that crash is caused by a bug in the library, there is a workaround fix presented in spotinterface.cpp.

At line 420 there is instructions how to enable it, just comment and uncomment a few lines and you should be fine!


- momoski - 2010-11-16

Hi Akezeke,

Just to make sure before I start compiling:
Code:
421        //if you are using spotifylib (not openspotifylib) 0.0.3, use the iterate over the tracks instead
422        //  for (int index=0; index < sp_artistbrowse_num_tracks(result); index++)
423        //{
424        //sp_track *spTrack = sp_artistbrowse_track(result, index);
425        //sp_album *spAlbum = sp_track_album(spTrack);
426        //we want to populate the list with albums, but spotify returns tracks
427        //if ( tempalbum != spAlbum && sp_album_is_available(spAlbum))
428        for (int index = 0; index < sp_artistbrowse_num_albums(result); index++)
429        {
430          sp_album *spAlbum = sp_artistbrowse_album(result, index);
431          if ( sp_album_is_available(spAlbum))

Becomes

Code:
421        //if you are using spotifylib (not openspotifylib) 0.0.3, use the iterate over the tracks instead
[b]422        for (int index=0; index < sp_artistbrowse_num_tracks(result); index++)
423        {
424        sp_track *spTrack = sp_artistbrowse_track(result, index);
425        sp_album *spAlbum = sp_track_album(spTrack);[/b]
426        //we want to populate the list with albums, but spotify returns tracks
427        //if ( tempalbum != spAlbum && sp_album_is_available(spAlbum))
428        [i]//for (int index = 0; index < sp_artistbrowse_num_albums(result); index++)[/i]
429        [i]//{[/i]
430        [i]//sp_album *spAlbum = sp_artistbrowse_album(result, index);[/i]
431          if ( sp_album_is_available(spAlbum))

line 427 remains commented, and all other lines further down the code remain unchanged as well?

UPDATE: Can confirm this is correct. However a new minor issue has occured:
The albums are now retrieved without crashing. But I think since tracks are used to get the albums, the albums are repeated. Example: Search for Michael Jackson go into artists, select Michael Jackson, retrieves 4424 albums, because each album is repeated the number of times that it has in tracks, so 10 times the original thriller album. Is there another line that is supposed to handle that?


- akezeke - 2010-11-16

Yes, uncomment line 427 and 429 aswell, and you need a matching } further down at the for loop end


- akezeke - 2010-11-16

and there is probably an other linet where tempalbum =spAlbum, dont have the source here


- soder - 2010-11-16

I still haven't tried all this, but I have a question.

I have always used the Ubuntu PPAs (precompiled builds) and will continue to do so.

But can I in some way build my own version of XBMC with Spotify, and then just move some of them files to my downloaded PPA version?

/Söder


- momoski - 2010-11-16

I really don't know. My base installation was the XBMCFreak Live CD based on version 10 beta 2. I believe that one installation also uses the PPA thingy (sorry dont know all the terminology). When looking into the xbmcfreak forum I found out you can build it yourself. I guess the answer is yes. As far as I can tell from what I did, everything remained the same, meaning my ftstab file (with my local ntfs shares) is still there, my wifi settings are still there, the only thing changed is the spotify in the music library. Which I like very very much.Laugh


- momoski - 2010-11-17

Question about the workings of libspotify in XBMC.

If an album is added to the library, is it only added to the XBMC library? Can it also be added to a new Spotify playlist?
Can a single track be added to the library?

Are spotify playlists manipulated in anyway? E.g. can a playlist be created, tracks added to it, etc.?

I guess the current answer is no. But in the api.h I see there are functions to manipulate the playlist. Is this not implemented by choice?

On the spotify github I see there is also a spotify playlist api (https://github.com/spotify/playlist-api) with restful function calls. Is it an idea to start developing a plugin or add-on using that api instead of the lib, or is that api not sufficient enough?

I am sorry if my questions don't make any sense. I do know how to code using c-sharp well, if I can do some proof of concept on this I am willing to put some time in it. Unfortunately I cannot program in C or C++.


- stigroar - 2010-11-18

I am a noob in all kinds of ways... New to Ubuntu, new to XBMC and new to HTPC in general. Anyway, I just set up my Asrock 330HT with XBMCFreak's live CD. Does there exist a nice step by step guide for how to get Spotify working?

Nice work, all of you how contribute to XBMC! It rocks so far! Smile


- momoski - 2010-11-18

I myself used https://github.com/akezeke/spotyxbmc to get it to work. Although I still have some issues, I find it do-able. Just a quick explanation of what u need to do, so that you understand the context.

Normally in XBMC there are all kinds of add-ons and scripts that can be dowloaded and installed with a single touch of a button. Unfortunately Spotify has a different kind of licence agreement and needs a key, that makes it harder to develop as an addon. Plus off course there must be people willing to develop such and addon. Akezeke for instance is willing, but rather waits until the new addon framework for xbmc is released that makes it possible to write add-ons in C++, rather than Python (Python is the current development language for addons).

So far the background. The steps mentioned on the website, basically contain the following:
- Download libspotify and install it. Libspotify is the API released by Spotify.
- Download sources of XBMC (the LiveCD contains the binaries that are built on those sources).
- Apply the batch from Akezeke to the downloaded XBMC source files. The patch integrates Spotify into XBMC and applies also your personal key. A personal key can only be obtained if you are a premium subscriber to Spotify. No premium subscription is no Spotify in XBMC.
- Compile the whole thing and install. The install will overwrite your XBMC executable, but your XBMC settings will remain untouched.

That's it.


- joeranjensen - 2010-11-18

momoski Wrote:I myself used https://github.com/akezeke/spotyxbmc to get it to work. Although I still have some issues, I find it do-able. Just a quick explanation of what u need to do, so that you understand the context.

Normally in XBMC there are all kinds of add-ons and scripts that can be dowloaded and installed with a single touch of a button. Unfortunately Spotify has a different kind of licence agreement and needs a key, that makes it harder to develop as an addon. Plus off course there must be people willing to develop such and addon. Akezeke for instance is willing, but rather waits until the new addon framework for xbmc is released that makes it possible to write add-ons in C++, rather than Python (Python is the current development language for addons).

So far the background. The steps mentioned on the website, basically contain the following:
- Download libspotify and install it. Libspotify is the API released by Spotify.
- Download sources of XBMC (the LiveCD contains the binaries that are built on those sources).
- Apply the batch from Akezeke to the downloaded XBMC source files. The patch integrates Spotify into XBMC and applies also your personal key. A personal key can only be obtained if you are a premium subscriber to Spotify. No premium subscription is no Spotify in XBMC.
- Compile the whole thing and install. The install will overwrite your XBMC executable, but your XBMC settings will remain untouched.

That's it.

Is this possible to do under windows 7? or do I have to install xbmc live to get it working?


- momoski - 2010-11-18

Don't know. You would have to use libspotify for windows I guess. And I only see version 0.0.6 of that and no version 0.0.3. Akezeke's patch has been using version 0.0.3.


- alex84 - 2010-11-18

@momski

"- Download sources of XBMC (the LiveCD contains the binaries that are built on those sources)."

Can i compile xbmc source code on from the install of live cd. I have installed on disk from livecd, and would like to compile from that. I got alot of changes and other stuff on my pc now and would like not to lose them..

Cheers