Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
# not shared with .npmignore
/public/app.js
/public/app.css
/.idea
35 changes: 35 additions & 0 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ var importFileFilters = [
name: 'song',
fn: importFileAsSong,
},
{
name: 'mpd',
fn: importFileAsMpdPlaylist,
}
];

module.exports = Player;
Expand Down Expand Up @@ -2896,6 +2900,37 @@ function importFileAsZip(self, srcFullPath, filenameHintWithoutPath, cb) {
});
}

function importFileAsMpdPlaylist(self, srcFullPath, filenameHintWithoutPath, cb) {
var mpdPlaylist = fs.readFileSync(srcFullPath, {encoding: 'utf-8'}).trim().split("\n");
var oldSearchFields = self.libraryIndex.searchFields;
var items = [];
self.libraryIndex.searchFields = ['file'];
self.libraryIndex.rebuildAlbumTable();

for (var entity in mpdPlaylist) {
var match = self.libraryIndex.search('"' + mpdPlaylist[entity] + '"');

if (match.trackTable.length > 1) {
log.debug('more than one track found for ' + mpdPlaylist[entity]);
} else if (match.trackTable.length === 0) {
log.debug('no track found for ' + mpdPlaylist[entity]);
}
for (key in match.trackTable) {
items.push(match.trackTable[key]);
}
}

if (items.length > 0) {
var dbPlaylist = self.playlistCreate(uuid(), filenameHintWithoutPath);
self.playlistAddItems(dbPlaylist.id, items);
}

self.libraryIndex.searchFields = oldSearchFields ;
self.libraryIndex.rebuildAlbumTable();
cb();
}


// sort keys according to how they appear in the library
function sortTracks(tracks) {
var lib = new MusicLibraryIndex();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@
"scripts": {
"start": "node lib/server.js",
"build": "npm install && ./build",
"dev": "npm run build && node lib/server.js --verbose"
"dev": "npm run build && node --debug=5858 lib/server.js --verbose"
}
}