getVideoSize
This commit is contained in:
parent
3780fad9ae
commit
f294e8cee1
1 changed files with 17 additions and 3 deletions
|
@ -9,6 +9,7 @@ export default {
|
||||||
stringIsAValidurl,
|
stringIsAValidurl,
|
||||||
compressVideo,
|
compressVideo,
|
||||||
getVideoCodec,
|
getVideoCodec,
|
||||||
|
getVideoSize,
|
||||||
getMaxFileSize,
|
getMaxFileSize,
|
||||||
};
|
};
|
||||||
async function downloadVideo(urlArg, output, format = 'bestvideo*+bestaudio/best') {
|
async function downloadVideo(urlArg, output, format = 'bestvideo*+bestaudio/best') {
|
||||||
|
@ -93,10 +94,23 @@ async function getVideoCodec(input) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getMaxFileSize(guild) {
|
async function getVideoSize(urlArg, format = 'bestvideo*+bestaudio/best') {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
|
exec(`yt-dlp ${urlArg} -f ${format} -O "%(filesize,filesize_approx)s"`, (err, stdout, stderr) => {
|
||||||
|
if (err) {
|
||||||
|
reject(stderr);
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
console.error(stderr);
|
||||||
|
}
|
||||||
|
resolve(stdout / 1000000.0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getMaxFileSize(guild) {
|
||||||
|
return await new Promise((resolve) => {
|
||||||
const tier = guild.premiumTier;
|
const tier = guild.premiumTier;
|
||||||
console.log(tier);
|
|
||||||
switch (tier) {
|
switch (tier) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -109,7 +123,7 @@ async function getMaxFileSize(guild) {
|
||||||
resolve('100');
|
resolve('100');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
reject('An error has occured');
|
resolve('8');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue