mopidy / mopidy-spotify

Mopidy extension for playing music from Spotify
https://mopidy.com/ext/spotify/
Apache License 2.0
934 stars 108 forks source link

Track/Album cache #193

Open roosemberth opened 6 years ago

roosemberth commented 6 years ago

Hi, Is it possible to cache a song so that when we lose the TCP connection (ie. while roaming/unstable network) we can continue listening at least for a couple of minutes ?

Bonus points: Entire albums

jjok commented 5 years ago

That's probably a fairly grey area. Spotify's terms of use specifically say that you can't download the audio. You may be able to get away with caching the current track.

kingosticks commented 4 years ago

libspotify technically has support for offline sync and pyspotify supports that. But I don't know how you'd expose that here in Mopidy-Spotify and you'd have to decide what you wanted to cache so it doesn't sound like what you want.

Alternatively, you should be able to achieve the first part of this by increasing your audio/buffer_time config value. Possibly at the expense of increased latency.

adamcik commented 4 years ago

Don't know if we have an existing bug for this already, but I think the quickest way to get this working would be to have the extension register a new CLI sub-command with mopidy where you could mark e.g. playlists as available offline.

I.e. it would just be lookup the playlist and then set https://pyspotify.mopidy.com/en/latest/api/playlist/#spotify.Playlist.set_offline_mode depending on if we are adding or removing.

Thinking this through we could perhaps also have a magic Offline playlist. The playlist wouldn't exist in Spotify and just contain the playlists that are available offline. So the mechanism for controlling things would be adding a playlist to the offline playlist.

Either of these ways you sidestep us not having a clean way to add this generically in Mopidy with a new Core API concept, or adding support for extension provided API extensions. Either of which are not likely to happen fast.

jjok commented 4 years ago

I think https://github.com/mopidy/mopidy-gmusic/issues/161 could solve the original issue of unstable internet connection. It wouldn't necessarily help with making albums and playlists available offline.