pianobar
pianobar copied to clipboard
Feature Request - Caching songs for unreliable connections?
Subject of the issue
I live in a rural area with spotty internet, and recently thought it might be a fun project to create a local database (simple filesystem backed one, or SQLite blobs for more complexity) for caching songs played by pianobar, maybe 50 or 100 or some customizable number for each station.
The way I imagine it working is:
- Request a new song from Pandora
- Once you have the song information, try to retrieve it from the cache. If it's not available, download as normal and store it in the cache
- Perhaps add a CLI option to "always cache" a certain song
- As a matter of routine maintenance, purge any songs in the cache that are oldest, if the limit is exceeded (on startup, and maybe once an hour)
Does this sound like a feature you might consider pulling in, if I developed it? I'm looking for a personal project right now, and I've used this program every day for 5+ years, so I figure it's a small way to give back.
If not, would it be because of technical reasons? Project vision differences? Pandora EULA violations?
Lemme know what you think!
Your environment
- not relevant
Steps to reproduce
not relevant
Expected behaviour
Not relevant
Actual behaviour
Not relevant
I don’t like the way pianobar currently handles playback all by itself. It’s just a huge mess of threads, queues and mutex locks and – as you’ve noticed – still does not work for everyone.
My idea was to completely move playback to an external process like mpv, mpd, … pianobar would spawn a wrapper, which receives the playback URL (maybe artist and title as well). That command would then communicate with mpv via mpv’s RPC and send pianobar status information (mainly track total/elapsed time). And pianobar would forward play, pause and skip commands, which would be sent to mpv.
Caching would nicely fit into that, although I would not enable it by default. Are you up for that?
As a side-note: You can already increase the in-memory audio buffer via
the config option buffer_seconds = 100000
.
So I take it that would involve proper bindings to the underlying mpv library. Sounds like it might possibly be a huge project to take on as far as testing + regressions go, but I can look into it and comment back!
Does buffer_seconds
allow you to buffer multiple songs?
No, not the library and mpv was just an example. I meant that you literally run mpv <stream url>
and then control the process through its RPC. The same can probably done with mplayer, mpd and many more. But I’d do this outside of pianobar (i.e. a wrapper), so people can plug in their favorite music player easily without touching pianobar itself.
edit: No buffer_seconds only applies to the current song.