39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Opciones de entrada HTTP para ffprobe/ffmpeg con orígenes tipo Xtream / Jellyfin (Dispatcharr).
|
|
* Muchos backends exigen Referer/origin coherentes además del User-Agent.
|
|
*/
|
|
|
|
function deriveRefererFromUrl(inputUrl) {
|
|
try {
|
|
const u = new URL(inputUrl);
|
|
return `${u.origin}/`;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/** VOD pesado (Remux Jellyfin MKV/MP4, GOP largo) — probes más grandes. */
|
|
function isHeavyVodUrl(url) {
|
|
if (!url || typeof url !== 'string') return false;
|
|
const u = url.toLowerCase();
|
|
if (u.includes('/movie/') || u.includes('/series/')) return true;
|
|
if (/\.mkv\b/i.test(url) || /\.mp4\b/i.test(url)) return true;
|
|
return false;
|
|
}
|
|
|
|
function probeSizingForUrl(url) {
|
|
if (isHeavyVodUrl(url)) {
|
|
/** Microseconds; VOD Jellyfin/remux pueden necesitar leer bastante antes del analyze */
|
|
return { probesize: '32000000', analyzeduration: '45000000', heavy: true };
|
|
}
|
|
return { probesize: '8000000', analyzeduration: '8000000', heavy: false };
|
|
}
|
|
|
|
module.exports = {
|
|
deriveRefererFromUrl,
|
|
isHeavyVodUrl,
|
|
probeSizingForUrl
|
|
};
|