From 54a250b84c7fed824ee42e08f00efdf690af1063 Mon Sep 17 00:00:00 2001 From: IrosTheBeggar Date: Wed, 30 Oct 2019 01:18:30 -0400 Subject: [PATCH] fix windows m3u bugs --- modules/db-management/database-default-manager.js | 2 +- modules/file-explorer.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/db-management/database-default-manager.js b/modules/db-management/database-default-manager.js index 3beacc8..14c1248 100644 --- a/modules/db-management/database-default-manager.js +++ b/modules/db-management/database-default-manager.js @@ -88,7 +88,6 @@ function pullFromDB() { }); } - function recursiveScan(dir) { let files; try { @@ -150,6 +149,7 @@ function parseFile(thisSong) { } // Parse the file for metadata and store it in the DB + console.log(thisSong) return metadata.parseFile(thisSong, opt).then(thisMetadata => { return thisMetadata.common; }).catch(err => { diff --git a/modules/file-explorer.js b/modules/file-explorer.js index 3895340..55e11fb 100644 --- a/modules/file-explorer.js +++ b/modules/file-explorer.js @@ -12,7 +12,7 @@ exports.setup = function(mstream, program) { function getPathInfoOrThrow(req, pathString) { const pathInfo = program.getVPathInfo(pathString); - if (pathInfo == false) { + if (pathInfo === false) { throw {code: 500, json: { error: "Could not find file" }}; } if (!req.user.vpaths.includes(pathInfo.vpath)) { @@ -30,11 +30,11 @@ exports.setup = function(mstream, program) { const fileContents = fs.readFileSync(pathString).toString(); parser.push(fileContents); parser.end(); - let items = parser.manifest.segments.map(function (segment) { return segment.uri; }); - if (items.length == 0) { + let items = parser.manifest.segments.map(segment => { return segment.uri; }); + if (items.length === 0) { items = fileContents.split(/\r?\n/).filter(Boolean); } - return items.map(function (item) { return item.replace(/\\/g, "/"); }); + return items.map(item => { return item.replace(/\\/g, "/"); }); } function handleError(error, res) { @@ -148,7 +148,7 @@ exports.setup = function(mstream, program) { const songs = readPlaylistSongs(playlistPathInfo.fullPath); res.json({ contents: songs.map(function (song) { - return {type: getFileType(song), name: fe.basename(song), path: fe.join(playlistParentDir, song)} + return { type: getFileType(song), name: fe.basename(song), path: fe.join(playlistParentDir, song).replace(/\\/g, '/') } }) }) } catch (error) { @@ -161,7 +161,7 @@ exports.setup = function(mstream, program) { const playlistPathInfo = getPathInfoOrThrow(req, req.body.path); const playlistParentDir = fe.dirname(req.body.path); const songs = readPlaylistSongs(playlistPathInfo.fullPath); - res.json(songs.map(function (song) { return fe.join(playlistParentDir, song); })); + res.json(songs.map(function (song) { return fe.join(playlistParentDir, song).replace(/\\/g, '/'); })); } catch (error) { handleError(error, res); }