LMS-Cast icon indicating copy to clipboard operation
LMS-Cast copied to clipboard

How do I build the full plugin for testing? (v9 user defined roles)

Open scbash opened this issue 1 year ago • 0 comments

LMS Cast bridge has quickly become my most used method for listening to music from LMS. Thanks for a great plugin!

After updating LMS to 9.0.1 yesterday, I started experimenting with the new user defined artist roles -- I've historically tagged my music with a separate "DisplayArtist" field to have a human readable artist tag while the standard "Artist" tag is for library organization. I found that after defining a custom role in LMS, the v9 LMS CLI does return the user defined roles when prompted (A vs a), so this morning I hacked up a version of squeeze2cast using my specific role (patch below). Running it by hand works as expected.

I think a more usable form of this would be to add an "artist role" preference in the plugin web UI that defaults to "artist" but can be customized by the user to any of the known roles (and falls back to "artist" if the specified role isn't found in the metadata). I'm happy to keep working on this, but I haven't found documentation on how you build the full plugin? I'd like to at least simulate that locally to test installing the plugin and setting up the parameters myself. Any thoughts on that?

Thanks!

diff --git a/application/squeezelite/main.c b/application/squeezelite/main.c
index 3eef503..aecb345 100644
--- a/application/squeezelite/main.c
+++ b/application/squeezelite/main.c
@@ -342,7 +342,7 @@ uint32_t sq_get_metadata(sq_dev_handle_t handle, metadata_t *metadata, int token
        // use -1 to get what's playing
        if (token == -1) index = 0;
 
-       sprintf(cmd, "%s status - %d tags:xcfldatgrKNoITH", ctx->cli_id, index + 1);
+       sprintf(cmd, "%s status - %d tags:xcfldAtgrKNoITH", ctx->cli_id, index + 1);
        rsp = cli_send_cmd(cmd, false, false, ctx);
 
        if (!rsp || !*rsp) {
@@ -378,12 +378,20 @@ uint32_t sq_get_metadata(sq_dev_handle_t handle, metadata_t *metadata, int token
 
        if (cur) {
                metadata->title = cli_find_tag(cur, "title");
-               metadata->artist = cli_find_tag(cur, "artist");
                metadata->album = cli_find_tag(cur, "album");
                metadata->genre = cli_find_tag(cur, "genre");
                metadata->remote_title = cli_find_tag(cur, "remote_title");
                metadata->artwork = cli_find_tag(cur, "artwork_url");
 
+               // TODO: displayartist should be "artist role" preference set via web UI
+               if ((p = cli_find_tag(cur, "displayartist")) != NULL) {
+                       metadata->artist = p;
+                       LOG_INFO("[%p] found DisplayArtist! %s", ctx, metadata->artist);
+               } else {
+                       metadata->artist = cli_find_tag(cur, "artist");
+                       LOG_INFO("[%p] fell back to artist: %s", ctx, metadata->artist);
+               }
+
                if ((p = cli_find_tag(cur, "duration")) != NULL) {
                        /* when it's a repeating track, duration must hold the full block length while
                         * live_duration will hold the segment duration */

scbash avatar Dec 22 '24 21:12 scbash