Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrobbling to multiple servers? #39

Open
vjeranc opened this issue Apr 23, 2021 · 4 comments
Open

Scrobbling to multiple servers? #39

vjeranc opened this issue Apr 23, 2021 · 4 comments

Comments

@vjeranc
Copy link

vjeranc commented Apr 23, 2021

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.

@arkq
Copy link
Owner

arkq commented Apr 24, 2021

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

@vjeranc
Copy link
Author

vjeranc commented Apr 24, 2021

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:

  1. have multiple .conf files
  2. change cmusfm.conf to unnotified .conf
  3. call cmusfm
  4. go to 2 until all configurations are exhausted

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.

@arkq
Copy link
Owner

arkq commented Apr 24, 2021

The big picture of the cmusfm architecture is as follows:

  • during first launch, the cmusfm server is spawned
  • during second launch, cmusfm "client" sends data to server instance

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.

@vjeranc
Copy link
Author

vjeranc commented Apr 24, 2021

I understand you completely. Thanks for the info. I'll notify if I'll start developing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants