Skip to content

Commit

Permalink
Ensures album view orders albums by album artist
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Henning committed Jan 6, 2018
1 parent 5339c3b commit 77bb853
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions app/plugins/music_service/mpd/index.js
Expand Up @@ -14,12 +14,13 @@ var parser = require('cue-parser');
var mm = require('musicmetadata');
var os = require('os');
var execSync = require('child_process').execSync;
var timSort = require('timsort');
var ignoreupdate = false;
//tracknumbers variable below adds track numbers to titles if set to true. Set to false for normal behavour.
var tracknumbers = false;
//compilation array below adds different strings used to describe albumartist in compilations or 'multiple artist' albums
var compilation = ['Various','various','Various Artists','various artists','VA','va'];
//atistsort variable below will list artists by albumartist if set to true or artist if set to false
//artistsort variable below will list artists by albumartist if set to true or artist if set to false
var artistsort = true;
var dsd_autovolume = false;
var singleBrowse = false;
Expand Down Expand Up @@ -2992,11 +2993,20 @@ ControllerMpd.prototype.listAlbums = function (ui) {
uri: 'albums://' + encodeURIComponent(artistName) + '/'+ encodeURIComponent(albumName),
//Get correct album art from path- only download if not existent
albumart: self.getAlbumArt({artist: artistName, album: albumName}, self.getParentFolder('/mnt/' + path),'dot-circle-o')
};
};
response.navigation.lists[0].items.push(album);
}
}
}
}
}
}
// Sort albums by album artist, because the order produced by mpd is dependent on the
// filesystem from which the albums were read, i.e. if audio files are stored in the
// folders 'A' and 'B', then all albums in 'A' come before those in 'B'.
// Within 'A' and 'B' albums are typically sorted by album artist. Its partially
// sorted nature makes the albums array a good candidate for Timsort.
// https://en.wikipedia.org/wiki/Timsort
timSort.sort(response.navigation.lists[0].items, function (a, b) {
return a.artist.localeCompare(b.artist);
});
//Save response in albumList cache for future use
memoryCache.set("cacheAlbumList", response);
if(ui) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -56,11 +56,11 @@
"shelljs": "^0.7.8",
"socket.io": "^1.7.1",
"socket.io-client": "^1.7.4",
"sort-on": "^2.0.0",
"spotify-web-api-node": "^2.4.0",
"string": "^3.3.3",
"tail": "^1.2.2",
"telnet": "0.0.1",
"timsort": "^0.3.0",
"underscore": "^1.8.3",
"unirest": "^0.5.1",
"v-conf": "^1.4.0",
Expand Down

0 comments on commit 77bb853

Please sign in to comment.