Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Album missing in library view
#1
I've stumbled across an issue where the Moode UI “loses” albums when selecting via ARTISTS row on the Tags view (and also by album view)

Moode Version9.3.0 2025-03-21

Symptom: 
Clicking GENRE column yields correct entry on ARTISTS and ALBUMS columns, though the ALBUMS “artist” field says “Various”.
When clicking on the row in the ARTISTS column, the album disappears from the ALBUMS column and so is no longer selectable

Observation:
I have narrowed this behaviour down to a repeatable case with 2 tracks (which occurs similarly in a number of places in my library)
The  “artist” json array and the “album_artist” string are consistent in any given track, but between tracks on the same album there are case-only inconsistencies

For example 
         "Rage Against the Machine"
vs.    "Rage Against The Machine"
(notice the capitalised T on “the")

So we have 2 tracks on the same album but it appears the filtering of rows in ALBUMS from a selected row on ARTISTS is done on different criteria, where case sensitivity doesn’t play nicely.
Note this pattern is identical to albums with various artists (compilations/soundtracks) but they are somehow not treated in quite the same way - those strings are handled correctly, so it feels rooted in case sensitivity somewhere between ARTISTS row selection and the resulting ALBUMS.

Intriguingly, the ARTISTS row may have grouped case insensitively and displays the value based on the “album_artist” string - in this case, the first one is "Rage Against The Machine" and that’s the text displayed. Not sure if that is part of the issue or completely irrelevant, because it does not pick up either track - where you might expect it to detect one of them.
Everything is listed on the tracks panel when the GENRE row (or all) is selected, it only starts to fail when selecting entries further right - either ARTISTS or ALBUMS.



Sample /var/local/www/libcache_all.json to illustrate the issue:

[
  {
    "file": "NAS/Music/Rage Against the Machine/Evil Empire/11 Year Of Tha Boomerang.m4a",
    "tracknum": "11",
    "title": "Year Of Tha Boomerang",
    "disc": "1",
    "artist": [
      "Rage Against the Machine"
    ],
    "album_artist": "Rage Against the Machine",
    "composer": "Rage Against the Machine",
    "year": "199600",
    "album_year": "",
    "time": "240",
    "album": "Evil Empire",
    "genre": [
      "Rock"
    ],
    "time_mmss": "04:00",
    "last_modified": "2025-04-10T12:14:45Z",
    "encoded_at": "M4A 16/44.1,s,2",
    "comment": "",
    "mb_albumid": "0"
  },
  {
    "file": "NAS/Music/Rage Against the Machine/Evil Empire/02 Bulls On Parade.m4a",
    "tracknum": "2",
    "title": "Bulls On Parade",
    "disc": "1",
    "artist": [
      "Rage Against The Machine"
    ],
    "album_artist": "Rage Against The Machine",
    "composer": "Rage Against the Machine",
    "year": "199600",
    "album_year": "",
    "time": "231",
    "album": "Evil Empire",
    "genre": [
      "Rock"
    ],
    "time_mmss": "03:51",
    "last_modified": "2025-04-10T12:14:26Z",
    "encoded_at": "M4A 16/44.1,s,2",
    "comment": "",
    "mb_albumid": "0"
  }
]


FIX AT SOURCE:
I’ve fixed this for my own library by manually going through the UI to see where this "Various" entry occurs in the ALBUMS row's sub-text and fixing up the tags in the m4a & mp3 files via AtomicParsley (OSX) or id3v2 (linux) and making sure all artist names for a given album are consistent.

Thought this might be a useful helper should anyone observe this issue. 
I've not had a chance to look in detail at the javascript to see how all this hangs together, so not able to offer up a code fix.
Reply
#2
The JSON file is generated by
https://github.com/moode-player/moode/bl...ibrary.php

Library Tag and Album views are generated by
https://github.com/moode-player/moode/bl...library.js
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
perfect, thanks - I'll have a dig!
Reply
#4
Hi Tim,

Good news: I think I've found it.

Bad news: I don't have an environment set up to build and deploy the javascript...

I suspect the issue is in "scripts-library.js", where getAlbumArtist() doesn't do a case-insensitive reduction of the artists (L236 at current HEAD). 
It makes sense with everything else that is going on (AFAICT) in the code and is consistent with the symptoms I see, because the "Various" album artist would simply never match any of the tracks, so there would be no tracks in the track panel. Whether this is intended behaviour or not is a different question :0) 

This is the current code:

Code:
function getAlbumArtist(albumTracks){
   var allAlbumArtists = [];
   allAlbumArtists = albumTracks.reduce(function(acc,track){
       !acc.includes(track.album_artist) && acc.push(track.album_artist);
       return acc;
   },[]);
   return allAlbumArtists.length == 1 ? allAlbumArtists[0] : "Various";
}

I suspect should probably be as follows, which is based on inc/music_library.php always supplying a valid album_artist value (which is currently does)
Code:
function getAlbumArtist(albumTracks){
   var allAlbumArtists = [];
   allAlbumArtists = albumTracks.reduce(function(acc,track){
       // collect case-insensitively
       var artist = track.album_artist.toLowerCase()
       !acc.includes(artist) && acc.push(artist);
       return acc;
   },[]);
   if (allAlbumArtists.length == 1) {
       // music-library.php _always_ provides an album_artist field, so blindly return the first in the array
       return albumTracks[0].album_artist;
   }
   // none or many
   return "Various";
}

Apologies for not being able to test this, are you in a position to try it out at some point with the libcache_all.json above?

I just put the json in place and reloaded the browser which resulted in the php code simply picking up the cache file. I like the way that works - it did make it much easier to figure out what seemed to be the underlying cause.
Reply
#5
curiosity got the better of me - I noticed that in "scripts-library.js" there are various places where LIB.filters.artists make use of the canonical (lowercase) form such as in filterByArtist(), but there are a few places where its a plain lookup - in the click handler for "albumsList" all of the manipulation of the LIB.filters.artists is arbitrary so may yield silent matching failures/misses in the event of tags being set inconsistently on audio files from the same album as has happened to me (I was using Apple's Music app to rip CDs).

For example, c. L1044 does a plain

Code:
   if (alreadyActive && LIB.filters.artists.length && !LIB.filters.artists.includes(albumobj.album_artist)) {
and the filing code for the filter also uses arbitrary form (c. L1045-1056):
Code:
                var n = LIB.filters.artists.length;
                albumArtists.forEach(artist => (!LIB.filters.artists.includes(artist) && LIB.filters.artists.push(artist)));
                filterSongs();
and c. L1097-1100):
Code:
                LIB.filters.artists.push(albumobj.album_artist);
                filterSongs();
                LIB.filters.artists.pop();
                renderSongs()

Its less clear to me whether this is actually a problem so I'm reluctant to propose any code changes, but thought it useful to highlight.
Reply


Forum Jump: