So yeah, as the probably unnecessarily long title says, this is a CLI that displays the current playing lyrics, but instead of trying to go online and fetch a match it just uses the already there xesam:asText property in MPRIS.

Sadly a lot of popular players that implement the MPRIS2 standard still don't implement that specific one, so it wont work with them. Even the one used in the showcase had to be modified, tho I am hopefully gonna upstream it soon.

I am very strict about AI usage, so for this project the only hint of AI that was used was for tab auto completion that is just used for boilerplate like, idk, implementing the Default trait for PlayerState (not including the actual tricky metadata_last_updated part). Safe to say it was only one notch above no AI at all.

So yeah, here you go give it a try and feel free to roast me, after all this is my first cli and cargo publish ;)

showcase of the cli running: lyrics are synced and auto scrolling

all 5 comments

sorted by: hot top controversial new old
[–] 3 points 1 month ago

Alec Benjamin mentioned!

Neat project.

  • source
  • [–] 2 points 1 month ago (1 child)

    The Media Player Remote Interfacing Specification (MPRIS) is a standard D-Bus interface which aims to provide a common programmatic API for controlling media players.

    This metadata is only for media streams, not something that would be embedded as metadata in a file?

  • source
  • hideshow 1 child comment
  • [–] [S] 2 points 1 month ago

    MPRIS is the spec that Linux desktops use to make players transfer metadata about the thing they are playing and its state.

    For example: title, artists, cover art, position, playing/paused, etc...

    It doesn't specify where the metadata should come from, for example the xesam:asText can be populated with lyrics from the metadata embedded in the song file itself, a companion .lrc file or even fetched from lrclib by the player, as long as the player is the one doing the IO and populating it.

  • source
  • parent
  • [–] 2 points 1 month ago (1 child)

    There's another notch where you only ask questions and do the writing alone

  • source
  • hideshow 1 child comment
  • 3 comments in c/rust@lemmy.ml view that post
    [–] 7 points 1 month ago (2 children)

    Small nitpick that I noticed while skimming the code:

    Where you define your constants, you can change those comments to be doc-comments instead, so that your editor can display them when you hover over constants.

    And personally, I would go one step further with the units, by putting them at the end of the name of the constant, like you did with some variables in the code. That way, the unit shows up inline while reading code that uses the constant, which makes it easy to see that units match up (or not).

    Side-note: You don't have to denote the unit for Duration. You construct it from milliseconds, but then it's unitless and you decide where you use it in what unit you want the value. So, Duration is very cool and I would recommend using it for LRC_START_THRESHOLD as well.

    But yeah, back to the comments-thing: Plain comments are kind of inherently crappy, because they only show up in one place in the code, so you're less likely to see them and less likely to update them. By putting things into doc-comments, names, log statements, error messages etc., they show up in at least two places.
    Plain comments only really make sense for explaining why the code does something. The what can generally be explained in other ways, at least in a sufficiently abstracted language like Rust.

  • source
  • hideshow 2 child comments
  • [–] 4 points 1 month ago (1 child)

    Side-note: You don't have to denote the unit for Duration. You construct it from milliseconds, but then it's unitless and you decide where you use it in what unit you want the value. So, Duration is very cool and I would recommend using it for LRC_START_THRESHOLD as well.

    Expanding on this further, but the best kind of documentation for what a value represents is its type. Since all of these are duration-related, I would even go as far as using only Duration types for these. The values in Hz (aka n/sec) can be inversed to turn them into Durations (which happens below them to create REFRESH_DURATION and METADATA_REFRESH_DURATION which, despite their names, are actually intervals from what I can tell).

  • source
  • parent
  • hideshow 1 child comment
  • [–] [S] 4 points 1 month ago* (last edited 1 month ago)

    yeah, thinking about it, probably the naming of those isn't the best, will make sure to change them and use doc comments

    tho, I will probably keep the 2 Hz consts (while adding a _HZ in both their names) as they make it easier to understand imo [changed my mind: I guess it is easier if it is just the intervals]

    thank u both for actually caring :)

  • source
  • parent