raitonoberu / sptlrx

Synchronized lyrics in your terminal
MIT License
354 stars 14 forks source link

Support regex in players whitelist #33

Closed BachoSeven closed 6 months ago

BachoSeven commented 6 months ago

Use case: I'd been using sptlrx to get the lyrics for ncspot, a TUI Spotify player, and for a few versions it's not advertised as "ncspot" on MPRIS, but instead as ncspot.instancexxxxx, where xxxxx is a random number like 23409.

For this reason, it would be really useful to be able to write a regex such as

mpris:
  players: [ncspot.instance*, tauon, spotify]

instead of removing the whitelist altogether (which would mean that things like Chrome tabs get recognised as lyrics).

Thanks for making this project btw, it's awesome!

raitonoberu commented 6 months ago

This will definitely be added, how nice that Go has a built-in function for such matching :)

Thank you for staying here from the very beginning, I really appreciate it.

BachoSeven commented 6 months ago

By the way, I've given it a little more thought and the initial issue can be solved more systematically (and with less user intervention) by checking both for the player's Name and Name.instanceXXXXX, for players which allow multiple instances to be running at the same time as specificed in the MPRIS spec.

This is how it also was implemented in the rescrobbled project.

I can make another PR if you want, and I think that with hindsight there is no other reason for matching regexes (which was a workaround for this problem in the first place).

raitonoberu commented 6 months ago

This is a good find. I agree that this solution is much better. If you have some spare time, I would appreciate it if you could make a PR. The last release is still quite "hot", so we could release v1.2.1 without waiting another six months :)