Some fixes relative to job launch
This commit is contained in:
18
index.js
18
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) => {
|
||||
try {
|
||||
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 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`);
|
||||
|
||||
try {
|
||||
const filesExist = await checkFilesExistance('encrypted');
|
||||
|
||||
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')) {
|
||||
|
||||
@@ -207,6 +207,7 @@ const processUpdate = async (data) => {
|
||||
fs.renameSync(`${unzippedFolderDest}/${uncompressedFoldersS[0]}/${uncompressedFolders[0]}`, data.details.localInfos.path);
|
||||
else if (data.binType === 'mp4decrypt')
|
||||
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'])
|
||||
} catch(e) {
|
||||
throw e;
|
||||
|
||||
Reference in New Issue
Block a user