mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-13 00:41:29 +03:00
Fixed catch statements not having arguments on backend
Fixed backend location url not working when not in root dir on web server
This commit is contained in:
@@ -196,7 +196,7 @@ function deleteAudioFile(name) {
|
|||||||
for (let i = 0; i < descriptors[name].length; i++) {
|
for (let i = 0; i < descriptors[name].length; i++) {
|
||||||
descriptors[name][i].destroy();
|
descriptors[name][i].destroy();
|
||||||
}
|
}
|
||||||
} catch {
|
} catch(e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,7 +235,7 @@ async function deleteVideoFile(name) {
|
|||||||
for (let i = 0; i < descriptors[name].length; i++) {
|
for (let i = 0; i < descriptors[name].length; i++) {
|
||||||
descriptors[name][i].destroy();
|
descriptors[name][i].destroy();
|
||||||
}
|
}
|
||||||
} catch {
|
} catch(e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@ function getAudioInfos(fileNames) {
|
|||||||
let data = fs.readFileSync(fileLocation);
|
let data = fs.readFileSync(fileLocation);
|
||||||
try {
|
try {
|
||||||
result.push(JSON.parse(data));
|
result.push(JSON.parse(data));
|
||||||
} catch {
|
} catch(e) {
|
||||||
console.log(`ERROR: Could not find info for file ${fileName}.mp3`);
|
console.log(`ERROR: Could not find info for file ${fileName}.mp3`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,7 @@ function getVideoInfos(fileNames) {
|
|||||||
let data = fs.readFileSync(fileLocation);
|
let data = fs.readFileSync(fileLocation);
|
||||||
try {
|
try {
|
||||||
result.push(JSON.parse(data));
|
result.push(JSON.parse(data));
|
||||||
} catch {
|
} catch(e) {
|
||||||
console.log(`ERROR: Could not find info for file ${fileName}.mp4`);
|
console.log(`ERROR: Could not find info for file ${fileName}.mp4`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -306,8 +306,7 @@ async function getUrlInfos(urls) {
|
|||||||
try {
|
try {
|
||||||
try_putput = JSON.parse(output);
|
try_putput = JSON.parse(output);
|
||||||
result = try_putput;
|
result = try_putput;
|
||||||
}
|
} catch(e) {
|
||||||
catch {
|
|
||||||
// probably multiple urls
|
// probably multiple urls
|
||||||
console.log('failed to parse');
|
console.log('failed to parse');
|
||||||
console.log(output);
|
console.log(output);
|
||||||
@@ -356,17 +355,15 @@ app.post('/tomp3', function(req, res) {
|
|||||||
let output_json = null;
|
let output_json = null;
|
||||||
try {
|
try {
|
||||||
output_json = JSON.parse(output[i]);
|
output_json = JSON.parse(output[i]);
|
||||||
} catch {
|
} catch(e) {
|
||||||
output_json = null;
|
output_json = null;
|
||||||
}
|
}
|
||||||
if (!output_json) {
|
if (!output_json) {
|
||||||
// only run on first go
|
// only run on first go
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var modified_file_name = output_json ? output_json['title'] : null;
|
var file_name = output_json['_filename'].replace(/^.*[\\\/]/, '');
|
||||||
var file_path = output_json['_filename'].split('\\');
|
var alternate_file_name = file_name.substring(0, file_name.length-4);
|
||||||
var alternate_file_name = file_path[file_path.length - 1];
|
|
||||||
alternate_file_name = alternate_file_name.substring(0, alternate_file_name.length-4);
|
|
||||||
if (alternate_file_name) file_names.push(alternate_file_name);
|
if (alternate_file_name) file_names.push(alternate_file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,25 +412,24 @@ app.post('/tomp4', function(req, res) {
|
|||||||
let output_json = null;
|
let output_json = null;
|
||||||
try {
|
try {
|
||||||
output_json = JSON.parse(output[i]);
|
output_json = JSON.parse(output[i]);
|
||||||
} catch {
|
} catch(e) {
|
||||||
output_json = null;
|
output_json = null;
|
||||||
}
|
}
|
||||||
var modified_file_name = output_json ? output_json['title'] : null;
|
var modified_file_name = output_json ? output_json['title'] : null;
|
||||||
if (!output_json) {
|
if (!output_json) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var file_path = output_json['_filename'].split('\\');
|
var file_name = output_json['_filename'].replace(/^.*[\\\/]/, '');
|
||||||
|
|
||||||
// renames file if necessary due to bug
|
// renames file if necessary due to bug
|
||||||
if (!fs.existsSync(output_json['_filename'] && fs.existsSync(output_json['_filename'] + '.webm'))) {
|
if (!fs.existsSync(output_json['_filename'] && fs.existsSync(output_json['_filename'] + '.webm'))) {
|
||||||
try {
|
try {
|
||||||
fs.renameSync(output_json['_filename'] + '.webm', output_json['_filename']);
|
fs.renameSync(output_json['_filename'] + '.webm', output_json['_filename']);
|
||||||
console.log('Renamed ' + file_path + '.webm to ' + file_path);
|
console.log('Renamed ' + file_name + '.webm to ' + file_name);
|
||||||
} catch {
|
} catch(e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var alternate_file_name = file_path[file_path.length - 1];
|
var alternate_file_name = file_name.substring(0, file_name.length-4);
|
||||||
alternate_file_name = alternate_file_name.substring(0, alternate_file_name.length-4);
|
|
||||||
if (alternate_file_name) file_names.push(alternate_file_name);
|
if (alternate_file_name) file_names.push(alternate_file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,10 @@ export class PostsService {
|
|||||||
if (isDevMode()) {
|
if (isDevMode()) {
|
||||||
return this.http.get('./assets/default.json');
|
return this.http.get('./assets/default.json');
|
||||||
}
|
}
|
||||||
console.log('Config location: ' + window.location.href + 'backend/config/default.json');
|
const locations = window.location.href.split('#');
|
||||||
return this.http.get(window.location.href + 'backend/config/default.json');
|
const current_location = locations[0];
|
||||||
|
console.log('Config location: ' + current_location + 'backend/config/default.json');
|
||||||
|
return this.http.get(current_location + 'backend/config/default.json');
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteFile(name: string, isAudio: boolean) {
|
deleteFile(name: string, isAudio: boolean) {
|
||||||
|
|||||||
Reference in New Issue
Block a user