From 5339c3baaa1d110d2db5a8c81ccfc92e45830d49 Mon Sep 17 00:00:00 2001 From: Andreas Henning Date: Sat, 6 Jan 2018 11:04:28 +0100 Subject: [PATCH 1/2] Also ignore Visual Studio Code configurations --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index a95f1bf77..d88932aa4 100755 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ lib-cov # Coverage directory used by tools like istanbul coverage +# Configuration directory used by Visual Studio Code +.vscode + # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt From 77bb8533cd0cd30d7e55facd1490ef4f8322f254 Mon Sep 17 00:00:00 2001 From: Andreas Henning Date: Sat, 6 Jan 2018 11:06:43 +0100 Subject: [PATCH 2/2] Ensures album view orders albums by album artist --- app/plugins/music_service/mpd/index.js | 20 +++++++++++++++----- package.json | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/plugins/music_service/mpd/index.js b/app/plugins/music_service/mpd/index.js index 320606d14..79098a4ed 100644 --- a/app/plugins/music_service/mpd/index.js +++ b/app/plugins/music_service/mpd/index.js @@ -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; @@ -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) { diff --git a/package.json b/package.json index a3b2525e5..9531e81ad 100644 --- a/package.json +++ b/package.json @@ -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",