Compare commits
2 commits
7c4bd84486
...
55b94d0021
Author | SHA1 | Date | |
---|---|---|---|
55b94d0021 | |||
4f34191d2f |
3 changed files with 61 additions and 41 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "dsr",
|
"name": "dsr",
|
||||||
"version": "1.11.0",
|
"version": "1.11.1",
|
||||||
"description": "Discord Video Sharing",
|
"description": "Discord Video Sharing",
|
||||||
"main": "./dist/main.js",
|
"main": "./dist/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
19
src/main.ts
19
src/main.ts
|
@ -144,7 +144,9 @@ app.whenReady().then(() => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Reduce size of a file */
|
/** Reduce size of a file
|
||||||
|
* Returns an empty string in case of failing
|
||||||
|
*/
|
||||||
const reduceSize = async (
|
const reduceSize = async (
|
||||||
file: string,
|
file: string,
|
||||||
bitrate: number,
|
bitrate: number,
|
||||||
|
@ -153,9 +155,11 @@ app.whenReady().then(() => {
|
||||||
const audioBitrate = Math.ceil(
|
const audioBitrate = Math.ceil(
|
||||||
audioTracks.reduce((sum, current) => current + sum, 0)
|
audioTracks.reduce((sum, current) => current + sum, 0)
|
||||||
);
|
);
|
||||||
let videoBitrate = bitrate - audioBitrate;
|
const videoBitrate = bitrate - audioBitrate;
|
||||||
|
let finalFile;
|
||||||
|
|
||||||
const finalFile = getNewFilename(file, "Compressed - ");
|
if (videoBitrate > 0) {
|
||||||
|
finalFile = getNewFilename(file, "Compressed - ");
|
||||||
|
|
||||||
// Trash the output, depends on the platform
|
// Trash the output, depends on the platform
|
||||||
const nul = process.platform === "win32" ? "NUL" : "/dev/null";
|
const nul = process.platform === "win32" ? "NUL" : "/dev/null";
|
||||||
|
@ -207,11 +211,14 @@ app.whenReady().then(() => {
|
||||||
"${finalFile}"`
|
"${finalFile}"`
|
||||||
).catch((e) => registerError(win, e));
|
).catch((e) => registerError(win, e));
|
||||||
|
|
||||||
// Delete the old video file
|
|
||||||
deleteFile(file);
|
|
||||||
|
|
||||||
// Delete the 2 pass temporary files
|
// Delete the 2 pass temporary files
|
||||||
deleteTwoPassFiles(process.cwd());
|
deleteTwoPassFiles(process.cwd());
|
||||||
|
} else {
|
||||||
|
finalFile = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the old video file
|
||||||
|
deleteFile(file);
|
||||||
|
|
||||||
return finalFile;
|
return finalFile;
|
||||||
};
|
};
|
||||||
|
|
|
@ -103,6 +103,7 @@ const main = async () => {
|
||||||
updateMessage("Récupération des fichiers...");
|
updateMessage("Récupération des fichiers...");
|
||||||
const files = await getFiles();
|
const files = await getFiles();
|
||||||
let processedFiles = "";
|
let processedFiles = "";
|
||||||
|
let numberOfUncompressableFiles = 0;
|
||||||
|
|
||||||
// Iterate over all the retrieved files
|
// Iterate over all the retrieved files
|
||||||
for (const [idx, file] of files.entries()) {
|
for (const [idx, file] of files.entries()) {
|
||||||
|
@ -148,14 +149,26 @@ const main = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append title to the list of processed files
|
// Append title to the list of processed files
|
||||||
|
if (finalTitle.length > 0) {
|
||||||
processedFiles += `\n- ${finalTitle}`;
|
processedFiles += `\n- ${finalTitle}`;
|
||||||
updateMessage(`Fichier ${counter} traités.`);
|
updateMessage(`Fichier ${counter} traités.`);
|
||||||
|
} else {
|
||||||
|
processedFiles += `\n- ${file} [incompressable]`;
|
||||||
|
updateMessage(`Fichier ${counter} trop large pour être compressé.`);
|
||||||
|
numberOfUncompressableFiles++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let errorMessage = "";
|
||||||
|
if (numberOfUncompressableFiles > 0) {
|
||||||
|
errorMessage += `\nNombre de fichier incompressable : ${numberOfUncompressableFiles}.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send confirmation to the user that we're done
|
// Send confirmation to the user that we're done
|
||||||
await internals.confirmation(
|
await internals.confirmation(
|
||||||
`${files.length} fichiers traités : ${processedFiles}`
|
`${files.length} fichiers traités : ${processedFiles}` + errorMessage
|
||||||
);
|
);
|
||||||
|
|
||||||
await internals.exit();
|
await internals.exit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue