wip: two m3u services filter -> isM3UService function

This commit is contained in:
mikhail 2024-05-22 14:28:48 +05:00
parent cf74d229a3
commit cadbeefd09
3 changed files with 11 additions and 6 deletions

View File

@ -5,12 +5,11 @@ import { nanoid } from "nanoid";
import { decryptStream, encryptStream, generateHmac } from "../sub/crypto.js";
import { env } from "../config.js";
import { strict as assert } from "assert";
import { isM3UService } from "./shared.js";
// optional dependency
const freebind = env.freebindCIDR && await import('freebind').catch(() => {});
const M3U_SERVICES = ['dailymotion', 'vimeo', 'rutube', 'nicovideo'];
const streamCache = new NodeCache({
stdTTL: env.streamLifespan,
checkperiod: 10,
@ -108,7 +107,7 @@ export function destroyInternalStream(url) {
function wrapStream(streamInfo) {
/* m3u8 links are currently not supported
* for internal streams, skip them */
if (M3U_SERVICES.includes(streamInfo.service)) {
if (isM3UService(streamInfo.service)) {
return streamInfo;
}

View File

@ -29,4 +29,10 @@ export function getHeaders(service) {
// Converting all header values to strings
return Object.entries({ ...defaultHeaders, ...serviceHeaders[service] })
.reduce((p, [key, val]) => ({ ...p, [key]: String(val) }), {})
}
}
const M3U_SERVICES = ["dailymotion", "vimeo", "rutube", "nicovideo"];
export function isM3UService(service) {
return M3U_SERVICES.includes(service);
}

View File

@ -6,7 +6,7 @@ import { create as contentDisposition } from "content-disposition-header";
import { metadataManager } from "../sub/utils.js";
import { destroyInternalStream } from "./manage.js";
import { env, ffmpegArgs } from "../config.js";
import { getHeaders, closeResponse } from "./shared.js";
import { getHeaders, closeResponse, isM3UService } from "./shared.js";
function toRawHeaders(headers) {
return Object.entries(headers)
@ -215,7 +215,7 @@ export function streamVideoOnly(streamInfo, res) {
args.push('-an')
}
if (["vimeo", "rutube", "dailymotion"].includes(streamInfo.service)) {
if (isM3UService(streamInfo.service)) {
args.push('-bsf:a', 'aac_adtstoasc')
}