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) => { return new Promise(async (resolve, reject) => {
try { try {
const files = await fs.readdir(process.cwd()); const files = fs.readdirSync(path);
resolve(files.filter(file => file.includes(pattern))); resolve(files.filter(file => file.includes(pattern)));
} catch(e) { } catch(e) {
reject(e); reject(e);
@@ -186,15 +186,15 @@ const extractPercentage = (line) => {
// Processus de la file d'attente // Processus de la file d'attente
videoQueue.process((job) => { videoQueue.process((job) => {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
try {
const { mp4Filename, mpdUrl, keys, wantedResolution } = job.data; 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 downloaderPath = softwareService.getLocalBinFileInfo('downloader').path;
const mp4decryptPath = path.join(process.env.HOME, 'Downloads/Bento4-SDK-1-6-0-641.universal-apple-macosx/bin/mp4decrypt'); const mp4decryptPath = softwareService.getLocalBinFileInfo('mp4decrypt').path;
const mp4TmpFilepath = path.join(TMP_PATH, `${mp4Filename}.mp4`); const mp4TmpFilepath = path.join(TMP_PATH, `${mp4Filename}.mp4`);
const mp4FinalFilepath = path.join(OUTPUT_PATH, `${mp4Filename}.mp4`); const mp4FinalFilepath = path.join(OUTPUT_PATH, `${mp4Filename}.mp4`);
console.log('1')
try { const filesExist = await checkFilesExistance('encrypted', TMP_PATH);
const filesExist = await checkFilesExistance('encrypted'); console.log('2')
if (filesExist.length === 0) { if (filesExist.length === 0) {
const resPattern = { const resPattern = {
'4k': [3840, 2160], '4k': [3840, 2160],
@@ -224,7 +224,7 @@ videoQueue.process((job) => {
job.progress(50); job.progress(50);
// Décryptage audio // Décryptage audio
const audioFiles = await fs.readdir('.'); const audioFiles = fs.readdirSync(mp4TmpFilepath);
const finalAudio = []; const finalAudio = [];
for (const file of audioFiles) { for (const file of audioFiles) {
if (file.startsWith(`${mp4TmpFilepath}_encrypted`) && file.endsWith('.m4a')) { if (file.startsWith(`${mp4TmpFilepath}_encrypted`) && file.endsWith('.m4a')) {

View File

@@ -207,6 +207,7 @@ const processUpdate = async (data) => {
fs.renameSync(`${unzippedFolderDest}/${uncompressedFoldersS[0]}/${uncompressedFolders[0]}`, data.details.localInfos.path); fs.renameSync(`${unzippedFolderDest}/${uncompressedFoldersS[0]}/${uncompressedFolders[0]}`, data.details.localInfos.path);
else if (data.binType === 'mp4decrypt') else if (data.binType === 'mp4decrypt')
fs.renameSync(`${unzippedFolderDest}/${uncompressedFoldersS[0]}/bin/mp4decrypt`, data.details.localInfos.path); fs.renameSync(`${unzippedFolderDest}/${uncompressedFoldersS[0]}/bin/mp4decrypt`, data.details.localInfos.path);
fs.chmodSync(data.details.localInfos.path, 0o755);
writeBinVersion(`${BIN_PATH}/.${data.binType}.version`, data.details.remoteInfos[data.binType === 'downloader' ? 'id' : 'version']) writeBinVersion(`${BIN_PATH}/.${data.binType}.version`, data.details.remoteInfos[data.binType === 'downloader' ? 'id' : 'version'])
} catch(e) { } catch(e) {
throw e; throw e;