Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Spotify for foobar (foo_input_spotify) New! (Read 56878 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Spotify for foobar (foo_input_spotify) New!

Hi!

Searching in internet to find a plugin for playing my spotify list (premium account) on my beloved foorbar, I came across this webpage

http://cpancake.me/spotify-on-foobar2000.html

The guy has taken an old spotify not working plugin and has made a new one that works very well! You start foobar2000 and go to File > Add Location (or press Ctrl-U). This will bring up the "Add Location" menu, then you take a spotify URI from the official client, like "spotify:track:5IRkM1WyCMDXPnabEeqz5i" or "spotify:user:communistpancake:playlist:2jYKvcXFolpUexOaOX3r7h" and this add the track(s) to your playlist!! the search track is working too!

You have to add manually each playlist from your spotify official client. If you add an new song  in the spotify official client you have to "reload" the playlist in the  "Add Location" menu of foobar. Actually the spotify playlist address is not changing , it remains the same.

I was just wondering if I can make it easier to do this procedure, via a script or something. Does anyone have any idea or inspiration of how to do this?

Thank you in advance!

Re: Spotify for foobar (foo_input_spotify) New!

Reply #1
it works flawlessly! thanks

I took the liberty to ask the dev about the possibility of fetching the album/track artwork as well.

Re: Spotify for foobar (foo_input_spotify) New!

Reply #2
Hi!!
You are welcome!
Did he reply to you?

Re: Spotify for foobar (foo_input_spotify) New!

Reply #3
The last time I used libspotify, it couldn't decode multiple tracks at the same time and was very thread-unsafe. Has that been addressed with this component or is it a ticking bomb?
Stay sane, exile.

Re: Spotify for foobar (foo_input_spotify) New!

Reply #4
Given that libspotify was last updated in 2013 the situation probably hasn't changed much. It can still only decode one track at a time. At least the plugin includes safeguards to handle this.

Re: Spotify for foobar (foo_input_spotify) New!

Reply #5
I doubt it will ever decode multiple tracks at once. That would be equivalent to Spotify allowing a single account to stream from multiple clients simultaneously, each with different tracks. Nope, not going to happen. Well, unless you want to get one of those Family accounts and use up all of your family quota with a single player.

Re: Spotify for foobar (foo_input_spotify) New!

Reply #6
Anyone know if by default, playing a URI code from Spotify gives you 320 KB/s quality?  Cause technically, by default, in every version of Spotify, even as a Premium user you always have to toggle that option.  If this isn't a known fact, perhaps the only way is by comparing the waveform from each source and comparing it.

Also, it would be incredible if the following additional things were also possible to do.  I sent Andrew Rogers this request on the page this was posted:
"Any chance of making the track numbers 1-(whatever is the total number of all the songs) when adding a playlist URI?  This would allow you to order it by name/artists if necessary and then reorder it back to how it originally was.  It would give it a more authentic look as well I would imagine.  That would be awesome, though this is really incredible already!  Thank you!  A lot you can actually do with this, apart from convenience of mixing different sources and being able to utilize Foobar's DSP.

Also, it would be amazing if upon going to the playlist tab in Foobar where you placed a playlist URI from Spotify, it auto-updates/reloads the playlist automatically to add any possibly new songs which were added.  That way, you can pretty much literally open Foobar to listen to your Starred list (for example) on shuffle and not have to worry about opening Spotify, re-copying, and re-adding the playlist location into the Foobar playlist every time manually.  If it was smart enough to compare and only add the new files, that would be even more awesome, not having to replace the old ones (saving time and possibly not screwing up your order) and adding the new tracks with track numbers x+1 (x being the highest number currently in the playlist)."

Re: Spotify for foobar (foo_input_spotify) New!

Reply #7
Given that Spotify has announced to shut down libspotify in 2017 any work spent on the foo_input_spotify plugin is probably in vain. Nevertheless I have tinkered with it a bit. After several hours of intense refactoring and bug fixing the login handling still leaves a lot to be desired UX wise. Under the hoods it had become rather easy to add album art support though. There is no proper release yet but you can find a link to the latest build on my GitHub repo.

Re: Spotify for foobar (foo_input_spotify) New!

Reply #8
Given that Spotify has announced to shut down libspotify in 2017 any work spent on the foo_input_spotify plugin is probably in vain. Nevertheless I have tinkered with it a bit. After several hours of intense refactoring and bug fixing the login handling still leaves a lot to be desired UX wise. Under the hoods it had become rather easy to add album art support though. There is no proper release yet but you can find a link to the latest build on my GitHub repo.

Wait, so you're Andrew Rogers, or you picked up where he left off?

In any case, so once they terminate it, this won't work anymore at all?  Would they have something to take its place and would it therefore still be possible to develop some alternative?

My main concern now has actually become the first thing I mentioned.  I just tried comparing Foobar with Spotify, and the songs in Foobar (to varying degrees) are significantly quieter.  Obviously the quieter relatively always sounds worse so it's hard to tell if it's playing at a lower bitrate or not, but the fact that there's any difference at all is concerning.  The option in Spotify to play all tracks back at the same volume isn't enabled on Spotify, Foobar is on full volume, and my DSP chain is as simple as it can get, to otherwise match the output from Spotify.  Is there any way within libspotify that this could be affected?

Re: Spotify for foobar (foo_input_spotify) New!

Reply #9
Wait, so you're Andrew Rogers, or you picked up where he left off?
No, I'm not Andrew Rogers and never have been. ;)

In any case, so once they terminate it, this won't work anymore at all?
That is to be expected.

Would they have something to take its place and would it therefore still be possible to develop some alternative?
They have APIs for web and mobile applications but nothing for desktop applications which could take the place of libspotify.

Re: Spotify for foobar (foo_input_spotify) New!

Reply #10
fb2k crashes when I add a Spotify track. From the crash report:

Code: [Select]
Illegal operation:
Code: C0000005h, flags: 00000000h, address: 058AC7C0h
Access violation, operation: read, address: 00000000h
Last win32 error: 3

Call path:
threaded_process thread=>playlist_loader::g_process_path=>index_tracks_helper=>hintable=>input_entry::g_open_for_info_read

Code bytes (058AC7C0h):
058AC780h:  8B 4E 04 E8 58 C4 F5 FF 8B 0E E9 51 C4 F5 FF CC
058AC790h:  6A FF 68 9B CB 8F 05 64 A1 00 00 00 00 50 64 89
058AC7A0h:  25 00 00 00 00 83 EC 08 55 56 8B 74 24 20 57 C7
058AC7B0h:  06 24 FF 91 05 C7 44 24 1C 04 00 00 00 8B 4E 04
058AC7C0h:  8B 01 8B 90 70 01 00 00 FF D2 33 FF 39 7E 04 74
058AC7D0h:  10 8B 4E 04 89 7E 04 8B 01 8B 90 74 01 00 00 FF
058AC7E0h:  D2 8B 86 C0 01 00 00 3B C7 74 09 50 E8 84 F4 02
058AC7F0h:  00 83 C4 04 E8 27 BC FB FF E8 22 F9 F4 FF C6 44

Re: Spotify for foobar (foo_input_spotify) New!

Reply #11
That excerpt from the crash report is not that useful to me. However I am guessing the crash location is within libspotify because I could provoke at crash was well and the code bytes look the same.
[codebox]
Crash location:
Module: libspotify
Offset: DC7C0h
[/codebox]
Do you have a second copy of foobar2000 running which also has foo_input_spotify installed? Libspotify needs a cache directory. The plugin uses the a directory within the Windows user profile as per the recommendation in the Libspotify SDK. It always uses the same directory, no matter where foobar2000 is installed or where the foobar2000 configuration directory is. This means any two installations of foobar2000 will use the same cache directory, no matter whether they are normal or portable installations.

Apparently Libspotify does not fail gracefully, i.e. by returning an error code, when the cache directory is already in use by another instance.

Re: Spotify for foobar (foo_input_spotify) New!

Reply #12
No, there was no other copy of foobar2000 running. However I used previously another version of foo_input_spotify. Maybe it corrupted the cache or something like this. Do you know what is the cache directory? I could try to delete it and see what happens.

Re: Spotify for foobar (foo_input_spotify) New!

Reply #13
The cache directory is at "%USERPROFILE%\AppData\Local\foo_input_spotify". If you paste this into the address field in Windows Explorer and press Return it will expand %USERPROFILE% to something like C:\Users\username-goes-here.

Re: Spotify for foobar (foo_input_spotify) New!

Reply #14
Funny, that directory doesn't exist.

Re: Spotify for foobar (foo_input_spotify) New!

Reply #15
In any case, so once they terminate it, this won't work anymore at all?
That is to be expected.

Would they have something to take its place and would it therefore still be possible to develop some alternative?
They have APIs for web and mobile applications but nothing for desktop applications which could take the place of libspotify.

This is quite unfortunate...  This awesome discovery is so short-lived...  You think there's any chance Spotify will ever be able to be played through Foobar again (since they only have API's for app and web platforms)?  Maybe somehow through the web API?

Btw, I tried the version you tinkered with and I still didn't see any album art (if it was supposed to do that).

Re: Spotify for foobar (foo_input_spotify) New!

Reply #16
I have since I think definitively been able to determine that the songs (at least most) DO NOT actually play in high quality (320 KB/s).  They are of significantly lower fidelity, when volume managed, to their directly from Spotify counterparts - quite noticeably actually.  Any ideas on if there a way of internally changing the source of the stream that's played back within the libspotify API?  If there's any one thing that's most important, at least in the meantime while there's still a chance to use it, it would be that.  Thanks!

Re: Spotify for foobar (foo_input_spotify) New!

Reply #17
That excerpt from the crash report is not that useful to me. However I am guessing the crash location is within libspotify because I could provoke at crash was well and the code bytes look the same.
[codebox]
Crash location:
Module: libspotify
Offset: DC7C0h
[/codebox]
Do you have a second copy of foobar2000 running which also has foo_input_spotify installed? Libspotify needs a cache directory. The plugin uses the a directory within the Windows user profile as per the recommendation in the Libspotify SDK. It always uses the same directory, no matter where foobar2000 is installed or where the foobar2000 configuration directory is. This means any two installations of foobar2000 will use the same cache directory, no matter whether they are normal or portable installations.

Apparently Libspotify does not fail gracefully, i.e. by returning an error code, when the cache directory is already in use by another instance.

Hang on, isnt libspotify still protected with Themida? Or have they upgraded the Spotify DRM to VMProtect 3/Denuvo or something?

Re: Spotify for foobar (foo_input_spotify) New!

Reply #18
Btw, I tried the version you tinkered with and I still didn't see any album art (if it was supposed to do that).
It is supposed to work. Later today or tomorrow I will add more logging to my code.

Hang on, isnt libspotify still protected with Themida? Or have they upgraded the Spotify DRM to VMProtect 3/Denuvo or something?
It is Themida. I found out when I started foobar2000 with foo_input_spotify after investigating some unrelated problem with the SysInternals Process Monitor. It displayed a message box, something about my computer being tainted by monitoring software. It crashed after I had clicked OK.

When another instance is already using the cache directory it crashes without displaying a message box.

Re: Spotify for foobar (foo_input_spotify) New!

Reply #19
It is supposed to work. Later today or tomorrow I will add more logging to my code.

I would imagine so XD.  I'm sure it installed and installed correctly though because when I did it without the libspotify.dll in the directory, it would fail to load songs entirely (obviously).  The previous install was through a ZIP which had the accompanying dll inside of it.  But yeah, so, not sure why it isn't.

With regards to the bitrate, I'm guessing you don't know? XD

Re: Spotify for foobar (foo_input_spotify) New!

Reply #20
I have updated the build process since my initial version so it now provides an fb2k-component file (a renamed ZIP file) containing the DLLs for the plugin and libspotify. I'm a little surprised about you saying it didn't load songs when you only grabbed the DLL. Foobar2000 should have complained about not being able to load the plugin when starting.

The libspotify library does not report the actual bitrate. There is a function to set the preferred bitrate for streaming (96, 160 or 320 kbps), but the plugin does not use this function. The library also has a volume normalization function, again the plugin does not use this. If the libspotify documentation describes a default value for either of these settings I haven't found it yet.

Re: Spotify for foobar (foo_input_spotify) New!

Reply #21
I have updated the build process since my initial version so it now provides an fb2k-component file (a renamed ZIP file) containing the DLLs for the plugin and libspotify. I'm a little surprised about you saying it didn't load songs when you only grabbed the DLL. Foobar2000 should have complained about not being able to load the plugin when starting.

The libspotify library does not report the actual bitrate. There is a function to set the preferred bitrate for streaming (96, 160 or 320 kbps), but the plugin does not use this function. The library also has a volume normalization function, again the plugin does not use this. If the libspotify documentation describes a default value for either of these settings I haven't found it yet.

Hmm, so you're saying it should've worked just by loading the fb2k-component file...  Hmm, well, so then I'll just try uninstalling and removing everything and then installing it.  Maybe it actually didn't load properly then even though it was working.

If you mention there is a function to set the preferred bitrate, can't it more or less be easily set in the plug-in?  I have no idea what I'm talking about (well, as far as how the plug-in works) so maybe not XD.  I imagine if it were, you would've already done it XD

Re: Spotify for foobar (foo_input_spotify) New!

Reply #22
I have added log output to the code which loads album art from Spotify. I should have mentioned before that the supported image types depend on the Spotify link type. The following table summarizes the currently supported image types:

Link typeArtist imageAlbum image
Artist linkyesno
Album linkyesyes
Track linkyesyes
Playlist linknoyes (playlist image, if available)

Re: Spotify for foobar (foo_input_spotify) New!

Reply #23
I have added log output to the code which loads album art from Spotify. I should have mentioned before that the supported image types depend on the Spotify link type. The following table summarizes the currently supported image types:

Link typeArtist imageAlbum image
Artist linkyesno
Album linkyesyes
Track linkyesyes
Playlist linknoyes (playlist image, if available)

Hmm..  Don't know what to tell you.

I removed every trace of the component and libspotify DLL I previously had, restarted, and then installed yours.  I then newly imported every of the above variations and tried to switch through every option the album preview had in terms of what it displays.  Nothing seemed to work.  Obviously can't tell you why or otherwise any more than that.

Re: Spotify for foobar (foo_input_spotify) New!

Reply #24
Have you looked at the foobar2000 console window (View > Console)?