server: add updateTags message to update db
This commit is contained in:
parent
259f247290
commit
78cd66d8df
2 changed files with 30 additions and 0 deletions
|
|
@ -51,6 +51,13 @@ var DB_FILE_PROPS = [
|
|||
'composerName', 'performerName', 'lastQueueDate',
|
||||
];
|
||||
|
||||
var EDITABLE_PROPS = [
|
||||
'name', 'artistName', 'albumArtistName',
|
||||
'albumName', 'compilation', 'track', 'trackCount',
|
||||
'disc', 'discCount', 'year', 'genre',
|
||||
'composerName', 'performerName'
|
||||
];
|
||||
|
||||
// how many GrooveFiles to keep open, ready to be decoded
|
||||
var OPEN_FILE_COUNT = 8;
|
||||
var PREV_FILE_COUNT = Math.floor(OPEN_FILE_COUNT / 2);
|
||||
|
|
@ -860,6 +867,22 @@ Player.prototype.addToLibrary = function(args, cb) {
|
|||
});
|
||||
};
|
||||
|
||||
Player.prototype.updateTags = function(obj) {
|
||||
for (var key in obj) {
|
||||
var track = this.libraryIndex.trackTable[key];
|
||||
if (!track) continue;
|
||||
var props = obj[key];
|
||||
if (!props || typeof props !== 'object') continue;
|
||||
for (var i = 0; i < EDITABLE_PROPS.length; i += 1) {
|
||||
var prop = EDITABLE_PROPS[i];
|
||||
if (! (prop in props)) continue;
|
||||
track[prop] = props[prop];
|
||||
}
|
||||
this.persist(track);
|
||||
this.emit('updateDbTrack', track);
|
||||
}
|
||||
};
|
||||
|
||||
Player.prototype.insertTracks = function(index, keys, tagAsRandom) {
|
||||
if (keys.length === 0) return;
|
||||
if (index < 0) index = 0;
|
||||
|
|
|
|||
|
|
@ -113,6 +113,13 @@ PlayerServer.actions = {
|
|||
}
|
||||
},
|
||||
},
|
||||
'updateTags': {
|
||||
permission: 'admin',
|
||||
args: 'object',
|
||||
fn: function(self, client, obj) {
|
||||
self.player.updateTags(obj);
|
||||
},
|
||||
},
|
||||
'unsubscribe': {
|
||||
permission: 'read',
|
||||
args: 'string',
|
||||
|
|
|
|||
Loading…
Reference in a new issue