Some fixes relative to job launch
This commit is contained in:
24
index.js
24
index.js
@@ -158,10 +158,10 @@ app.post('/processUpdate', async (req, res, next) => {
|
||||
}
|
||||
});
|
||||
|
||||
const checkFilesExistance = (pattern) => {
|
||||
const checkFilesExistance = (pattern, path) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const files = await fs.readdir(process.cwd());
|
||||
const files = fs.readdirSync(path);
|
||||
resolve(files.filter(file => file.includes(pattern)));
|
||||
} catch(e) {
|
||||
reject(e);
|
||||
@@ -186,15 +186,15 @@ const extractPercentage = (line) => {
|
||||
// Processus de la file d'attente
|
||||
videoQueue.process((job) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const { mp4Filename, mpdUrl, keys, wantedResolution } = job.data;
|
||||
const downloaderPath = path.join(process.env.HOME, 'Downloads/N_m3u8DL-RE_Beta_osx-arm64/N_m3u8DL-RE');
|
||||
const mp4decryptPath = path.join(process.env.HOME, 'Downloads/Bento4-SDK-1-6-0-641.universal-apple-macosx/bin/mp4decrypt');
|
||||
const mp4TmpFilepath = path.join(TMP_PATH, `${mp4Filename}.mp4`);
|
||||
const mp4FinalFilepath = path.join(OUTPUT_PATH, `${mp4Filename}.mp4`);
|
||||
|
||||
try {
|
||||
const filesExist = await checkFilesExistance('encrypted');
|
||||
|
||||
const { mp4Filename, mpdUrl, keys, wantedResolution } = job.data;
|
||||
const downloaderPath = softwareService.getLocalBinFileInfo('downloader').path;
|
||||
const mp4decryptPath = softwareService.getLocalBinFileInfo('mp4decrypt').path;
|
||||
const mp4TmpFilepath = path.join(TMP_PATH, `${mp4Filename}.mp4`);
|
||||
const mp4FinalFilepath = path.join(OUTPUT_PATH, `${mp4Filename}.mp4`);
|
||||
console.log('1')
|
||||
const filesExist = await checkFilesExistance('encrypted', TMP_PATH);
|
||||
console.log('2')
|
||||
if (filesExist.length === 0) {
|
||||
const resPattern = {
|
||||
'4k': [3840, 2160],
|
||||
@@ -224,7 +224,7 @@ videoQueue.process((job) => {
|
||||
job.progress(50);
|
||||
|
||||
// Décryptage audio
|
||||
const audioFiles = await fs.readdir('.');
|
||||
const audioFiles = fs.readdirSync(mp4TmpFilepath);
|
||||
const finalAudio = [];
|
||||
for (const file of audioFiles) {
|
||||
if (file.startsWith(`${mp4TmpFilepath}_encrypted`) && file.endsWith('.m4a')) {
|
||||
@@ -264,7 +264,7 @@ videoQueue.process((job) => {
|
||||
}
|
||||
|
||||
// Nettoyage (commenté pour correspondre au script original)
|
||||
await runCommand(`rm ${mp4TmpFilepath}_encrypted* && rm ${mp4TmpFilepath}_decrypted*`);
|
||||
await runCommand(`rm ${mp4TmpFilepath}_encrypted* && rm ${mp4TmpFilepath}_decrypted*`);
|
||||
|
||||
job.progress(100);
|
||||
resolve({ message: `File fetched and decrypted with success: ${mp4Filename}.mp4`, filePath: `${mp4FinalFilepath}.mp4`, fileName: `${mp4Filename}.mp4` });
|
||||
|
||||
Reference in New Issue
Block a user