Open vjeranc opened 3 years ago
Would this be possible without much effort?
It depends how "clean" the solution should be. If you have countable number of servers, then you might duplicated the configuration and duplicate the scrobbling in the server code.
If this solution should be more generic, then it might be a little bit of work (not much, though). First of all, the configuration should be flexible to allow any number of services for which the scrobbling should occur. Then, the actual scrobbling code should be moved to a separate thread, and N-number of threads should be created (in order to prevent unresponsiveness in case of not responding server) - one for each server. And finally, every thread should be "notified" (send a message to all threads using e.g. SEQPACKET socket) when scrobbling is required. Basically, that's my idea, but maybe other ideas will be good as well.
If you (or anyone) will create PR I will review it of course. But on my part, I'm afraid that currently I've got not enough time for such change in this project - especially that I do not need such feature on my own. And to be clear, this project is not dead, I'm using cmusfm almost every day :D
Thanks for the reply. It's fine if your time is limited, I don't expect you to do any additional work. Just asking for some info.
I tried just changing the cmusfm.conf
for now. Is there some global state that prevents scrobbling twice?
My first idea was:
.conf
filescmusfm.conf
to unnotified .conf
cmusfm
I've modified the server loop to include re-initialization of scrobbling but it didn't work. The Now playing works for multiple servers, but only the first one gets the final scrobble.
I'm assuming there's some shared global data where one cmusfm
call makes it progress, so other ones do nothing.
If it's possible, one could separate the state (if it is file based) based on the configuration, so whenever a new configuration is made, the correct file is used.
The big picture of the cmusfm architecture is as follows:
The server instance keeps state for current playback, and uses it to infer whether scrobbling should be done or not (there are some rules specified by the last.fm).
The Now playing works for multiple servers, but only the first one gets the final scrobble.
Now playing is sent to server when you start playing new song, but is does not mean that the song shall be scrobbled (you may play it for 2 seconds only, and it does not count as a scrobble trigger). The actual scrobble is sent to the server when you stop current song or start now one. So, that's the reason for a global state (it's not file based, it is kept in the server instance).
The other problem with multi-server scrobble is the requirement to modify offline cache. Right now, if the server does not accept scrobbling (or e.g. there is no internet connection at the moment), all songs are "scrobbled" locally, and are synced later. With multi-server approach, such cache should be per-server.
I understand you completely. Thanks for the info. I'll notify if I'll start developing.
Would this be possible without much effort?
I've tried moving scrobbler initialization and other variables after rereading the
cmusfm.conf
change (in the server loop) but for some reason it ended up not working.