fixed bug where custom paths failed to stream

pull/21/head
Isaac Grynsztein 5 years ago
parent 2673f4ee98
commit 62a000b631

@ -697,7 +697,7 @@ app.post('/api/tomp4', function(req, res) {
// gets the status of the mp3 file that's being downloaded
app.post('/api/fileStatusMp3', function(req, res) {
var name = decodeURI(req.body.name + "");
var name = decodeURIComponent(req.body.name + "");
var exists = "";
var fullpath = audioFolderPath + name + ".mp3";
if (fs.existsSync(fullpath)) {
@ -719,7 +719,7 @@ app.post('/api/fileStatusMp3', function(req, res) {
// gets the status of the mp4 file that's being downloaded
app.post('/api/fileStatusMp4', function(req, res) {
var name = decodeURI(req.body.name);
var name = decodeURIComponent(req.body.name);
var exists = "";
var fullpath = videoFolderPath + name + ".mp4";
if (fs.existsSync(fullpath)) {
@ -919,7 +919,7 @@ app.post('/api/downloadFile', async (req, res) => {
let outputName = req.body.outputName;
let file = null;
if (!is_playlist) {
fileNames = decodeURI(fileNames);
fileNames = decodeURIComponent(fileNames);
if (type === 'audio') {
file = __dirname + '/' + audioFolderPath + fileNames + '.mp3';
} else if (type === 'video') {
@ -927,7 +927,7 @@ app.post('/api/downloadFile', async (req, res) => {
}
} else {
for (let i = 0; i < fileNames.length; i++) {
fileNames[i] = decodeURI(fileNames[i]);
fileNames[i] = decodeURIComponent(fileNames[i]);
}
file = await createPlaylistZipFile(fileNames, type, outputName);
}
@ -948,7 +948,7 @@ app.post('/api/deleteFile', async (req, res) => {
app.get('/api/video/:id', function(req , res){
var head;
let id = decodeURI(req.params.id);
let id = decodeURIComponent(req.params.id);
const path = "video/" + id + '.mp4';
const stat = fs.statSync(path)
const fileSize = stat.size
@ -988,7 +988,7 @@ app.get('/api/video/:id', function(req , res){
app.get('/api/audio/:id', function(req , res){
var head;
let id = decodeURI(req.params.id);
let id = decodeURIComponent(req.params.id);
let path = "audio/" + id + '.mp3';
path = path.replace(/\"/g, '\'');
const stat = fs.statSync(path)

@ -74,7 +74,7 @@ export class PlayerComponent implements OnInit {
for (let i = 0; i < this.fileNames.length; i++) {
const fileName = this.fileNames[i];
const baseLocation = (this.type === 'audio') ? this.audioFolderPath : this.videoFolderPath;
const fullLocation = this.baseStreamPath + baseLocation + encodeURI(fileName); // + (this.type === 'audio' ? '.mp3' : '.mp4');
const fullLocation = this.baseStreamPath + baseLocation + encodeURIComponent(fileName);
// if it has a slash (meaning it's in a directory), only get the file name for the label
let label = null;
const decodedName = decodeURIComponent(fileName);

Loading…
Cancel
Save