Some fixes relative to job launch
All checks were successful
ci / Image build (push) Successful in 51s
ci / Deployment (push) Successful in 10s

This commit is contained in:
Joris Bertomeu
2024-10-01 18:03:22 +02:00
parent 4802f808cf
commit de5a577190
2 changed files with 13 additions and 12 deletions

View File

@@ -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` });