add nitro flag

This commit is contained in:
Mylloon 2023-11-11 14:03:53 +01:00
parent df63747376
commit 61defcc7b0
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 20 additions and 4 deletions

View file

@ -12,6 +12,7 @@ Head to [the release page](https://git.mylloon.fr/Anri/dsr/releases/latest).
- [x] Support drag&drop
- [x] Keep the video under 25mb (discord limitation)
- [x] If already under the limit, the file won't be compressed
- [x] Nitro suppport via `/nitro` flag
- [x] Merge all audio files into one track, while keeping the original ones (keeping track's title too)
- [x] Support multiples files

View file

@ -17,9 +17,12 @@ let internals: {
/** Search for files */
const getFiles = async () => {
const allowedExtensions = (await internals.allowedExtensions()).extensions;
const argv = await internals.argv();
if (argv.length >= 2) {
const files = argv.slice(1);
const argvFiles = (await internals.argv())
.slice(1)
.filter((element) => !element.startsWith("/"));
if (argvFiles.length > 0) {
const files = argvFiles;
// Exit if a file isn't supported in the list
if (
@ -40,6 +43,18 @@ const getFiles = async () => {
return files;
};
/** Returns maximum allowed size for files in MB */
const fetchMaxSize = async () => {
const argv = await internals.argv();
if (argv.includes("/nitro")) {
// Nitro user
return 500;
}
// Free user
return 25;
};
/** Either replace the message, or add some info */
enum Mode {
Write,
@ -71,7 +86,7 @@ const updateMessage = (
/** Main function */
const main = async () => {
const maxSizeDiscord = 25;
const maxSizeDiscord = await fetchMaxSize();
updateMessage("Récupération des fichiers...");
const files = await getFiles();
let processedFiles = "";