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,6 +1,6 @@
import HLS from 'hls-parser';
import { maxVideoDuration } from "../../config.js";
import { env } from "../../config.js";
import { cleanString } from '../../sub/utils.js';
async function requestJSON(url) {
@@ -35,8 +35,8 @@ export default async function(obj) {
if (play.detail || !play.video_balancer) return { error: 'ErrorEmptyDownload' };
if (play.live_streams?.hls) return { error: 'ErrorLiveVideo' };
if (play.duration > maxVideoDuration)
return { error: ['ErrorLengthLimit', maxVideoDuration / 60000] };
if (play.duration > env.durationLimit * 1000)
return { error: ['ErrorLengthLimit', env.durationLimit / 60] };
let m3u8 = await fetch(play.video_balancer.m3u8)
.then(r => r.text())