mirror of
https://github.com/IrosTheBeggar/mStream.git
synced 2025-10-27 07:31:02 +00:00
fix windows m3u bugs
This commit is contained in:
parent
8bd1b7caf8
commit
54a250b84c
@ -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 => {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user