Hi all - coming into this discussion a little bit late.
Can anyone confirm that mopidy does work with the spotify premium offline feature? In other words, if I set a playlist/album to be available offline in Spotify - Mopidy will download and play it locally from a cache?
This has been consistently hitting me for the past few weeks now, and none of the previous solutions have worked for me (although it did look like maybe there’s an issue with MB0.6.0 where it erroneously sets the spotify cache_dir to “”, which prevents caching from what I could see).
After some digging, I’ve come to the belief that the reason this is an occasional issue is down to this piece of code in mopidy_spotify/session_manager.py:
def log_message(self, session, data):
"""Callback used by pyspotify"""
logger.debug('System message: %s' % data.strip())
if 'offline-mgr' in data and 'files unlocked' in data:
# XXX This is a very very fragile and ugly hack, but we get no
# proper event when libspotify is done with initial data loading.
# We delay the expensive refresh of Mopidy's playlists until this
# message arrives. This way, we avoid doing the refresh once for
# every playlist or other change. This reduces the time from
# startup until the Spotify backend is ready from 35s to 12s in one
# test with clean Spotify cache. In cases with an outdated cache
# the time improvements should be a lot greater.
if not self._initial_data_receive_completed:
self._initial_data_receive_completed = True
self.refresh_playlists()
...
def refresh_playlists(self):
"""Refresh the playlists in the backend with data from Spotify"""
if not self._initial_data_receive_completed:
logger.debug('Still getting data; skipped refresh of playlists')
return
The issue is that the initial data receive completed flag NEVER seems to be set. As the comment says, this is incredibly fragile, which is likely why this issue randomly appears and disappears!
I’m going to try locally to add a timeout to the logic - after 20s, just assume that the initial data receive has been completed and start returning playlists.
I think there are two things that would help here though -
Make the system more robust (!!)
Change the log message about skipping returning playlists to be INFO level, so it appears in logs by default, as it’s so catastrophic when it goes wrong, and at least that would allow people to diagnose it more easily
…scratch being clever - I just commented out the optimisation (the early return in refresh_playlists) and it’s all fixed for me!
I have a reasonably large set of playlists, several of them being reasonably large, and it only takes a couple seconds to boot up, so I guess I wasn’t gaining much from the optimisation anyway. YMMV!
This is the old version of mopidy-spotify. It doesn’t work like this in the
new version. Musicbox is still stuck with the old version and that’s my
fault. I’ve just not had any time lately.
I had a quick look at the musicbox source on github to see if I could help & make a pull request, but it looks like the barrier to entry is pretty high there - other than add a super filthy text replace line after installing mopidy-spotify I can’t see a way of effecting a change.
Hi- I’ve been unsuccesfully trying to get Pi Musicbox 6 to see Spotify playlists by either adding paths to cache_dir and serttings_dir in settings.ini, or commenting out these lines and deleting cache files. It sounds like you hack of session_manager.py is the next thing to try, however I am unfamiliar with how I would go about this i.e. I have no idea how to find/edit this code. I would be very grateful of dummies how to guide. Thanks!
Man, I’ve been dicking around with PMB 6 all day, no luck in getting the playlist cache to update properly. I know the playlists have been imported, since they’re all sitting in /var/lib/mopidy/spotify/Users/… but for whatever reason it just no worky worky.
Hope we can figure out a solid workaround before the next release.
had the same problem, did TheRealMolens trick and now it works like charm.
So if this is still a problem for you here are the steps:
login to to your musicbox by ssh
cd /usr/local/lib/python2.7/dist-packages/mopidy_spotify/
(if it’s not there on your musicbox you will find it by using “find . -name session_manager.py”)
nano session_manager.py
scroll down to
" def refresh_playlists(self):
""“Refresh the playlists in the backend with data from Spotify”""
if not self._initial_data_receive_completed:
logger.debug(‘Still getting data; skipped refresh of playlists’)
return
playlists = []
folders = []
"
make a “#” in the beginning of the line of the “return” that it looks like that:
def refresh_playlists(self):
""“Refresh the playlists in the backend with data from Spotify”""
if not self._initial_data_receive_completed:
logger.debug(‘Still getting data; skipped refresh of playlists’)
Its been very difficult and embarrasing to having to listen to my daughters Itunes playlist when outside!
As an Apple Airplay device - the Pi has worked flawlessly but it wouldn’t show up my own Spotify playlists and therefore I couldn’t play MY music via my Note 3
One simple commenting out of a line and all is well
some weeks ago as i set up my musicbox for the first time i could solve the problem, that not even one of my own spotify playlists appeared.
now i forgot, which steps i did to solve the problem, therefore i don’t know, if my actual problem is solved in this thread.
my problem now is, that the spotify playlist that are from spotify itself (like “mix of the week” and so on) don’t appear in the web interface. is there a solution already? thanks!
Certain playlists such as “Discover Weekly” and “Release Radar” are special playlists owned by user Spotify. Unfortunately these playlists can no longer be accessed in clients using libspotify (such as ours) due to incompatible changes Spotify have made in their service. Hopefully we can work around it but for now that is the state of affairs (more info here).
So, I’ve had this problem as well and fixed it with the # before return and it solved the problem for a long time.
Now all of a sudden none of the playlists will load. The # is still there and I do not have a cache folder like described.
My playlists page is completely empty.
Anyone any idea how to solve this without me having to reinstall the whole thing?
First off, Pi Musicbox is brilliant, Thanks so much to the creators. I resurrected a cool old Lasonic ghetto blaster which can now stream Spotify through the auxilliary!
So, I use my iPhone to control the music when I’m in the garden. However, although I can see my custom playlists, the actual tracks don’t load.
I noticed tonight that I can load the tracks in my computer browser no problem. Assuming it is a cache issue, i went to Settings-Safari-Clear History and Website Data and my playlists load! It’s not the best solution, but hopefully this will help someone else out there who controls Pi Musicbox through an iPhone.