api: add DURATION_LIMIT env variable

duration limit is now in seconds and customizable across instances
This commit is contained in:
wukko
2024-05-16 20:57:48 +06:00
parent b5c81084c8
commit d1e8929ee2
12 changed files with 29 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
import HLSParser from 'hls-parser';
import { maxVideoDuration } from '../../config.js';
import { env } from '../../config.js';
let _token;
@@ -73,8 +73,8 @@ export default async function({ id }) {
return { error: 'ErrorEmptyDownload' }
}
if (media.duration * 1000 > maxVideoDuration) {
return { error: ['ErrorLengthLimit', maxVideoDuration / 60000] };
if (media.duration > env.durationLimit) {
return { error: ['ErrorLengthLimit', env.durationLimit / 60] };
}
const manifest = await fetch(media.hlsURL).then(r => r.text()).catch(() => {});