mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 19:28:29 +00:00
wip: two m3u services filter -> isM3UService function
This commit is contained in:
parent
cf74d229a3
commit
cadbeefd09
@ -5,12 +5,11 @@ import { nanoid } from "nanoid";
|
|||||||
import { decryptStream, encryptStream, generateHmac } from "../sub/crypto.js";
|
import { decryptStream, encryptStream, generateHmac } from "../sub/crypto.js";
|
||||||
import { env } from "../config.js";
|
import { env } from "../config.js";
|
||||||
import { strict as assert } from "assert";
|
import { strict as assert } from "assert";
|
||||||
|
import { isM3UService } from "./shared.js";
|
||||||
|
|
||||||
// optional dependency
|
// optional dependency
|
||||||
const freebind = env.freebindCIDR && await import('freebind').catch(() => {});
|
const freebind = env.freebindCIDR && await import('freebind').catch(() => {});
|
||||||
|
|
||||||
const M3U_SERVICES = ['dailymotion', 'vimeo', 'rutube', 'nicovideo'];
|
|
||||||
|
|
||||||
const streamCache = new NodeCache({
|
const streamCache = new NodeCache({
|
||||||
stdTTL: env.streamLifespan,
|
stdTTL: env.streamLifespan,
|
||||||
checkperiod: 10,
|
checkperiod: 10,
|
||||||
@ -108,7 +107,7 @@ export function destroyInternalStream(url) {
|
|||||||
function wrapStream(streamInfo) {
|
function wrapStream(streamInfo) {
|
||||||
/* m3u8 links are currently not supported
|
/* m3u8 links are currently not supported
|
||||||
* for internal streams, skip them */
|
* for internal streams, skip them */
|
||||||
if (M3U_SERVICES.includes(streamInfo.service)) {
|
if (isM3UService(streamInfo.service)) {
|
||||||
return streamInfo;
|
return streamInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,3 +30,9 @@ export function getHeaders(service) {
|
|||||||
return Object.entries({ ...defaultHeaders, ...serviceHeaders[service] })
|
return Object.entries({ ...defaultHeaders, ...serviceHeaders[service] })
|
||||||
.reduce((p, [key, val]) => ({ ...p, [key]: String(val) }), {})
|
.reduce((p, [key, val]) => ({ ...p, [key]: String(val) }), {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const M3U_SERVICES = ["dailymotion", "vimeo", "rutube", "nicovideo"];
|
||||||
|
|
||||||
|
export function isM3UService(service) {
|
||||||
|
return M3U_SERVICES.includes(service);
|
||||||
|
}
|
||||||
|
@ -6,7 +6,7 @@ import { create as contentDisposition } from "content-disposition-header";
|
|||||||
import { metadataManager } from "../sub/utils.js";
|
import { metadataManager } from "../sub/utils.js";
|
||||||
import { destroyInternalStream } from "./manage.js";
|
import { destroyInternalStream } from "./manage.js";
|
||||||
import { env, ffmpegArgs } from "../config.js";
|
import { env, ffmpegArgs } from "../config.js";
|
||||||
import { getHeaders, closeResponse } from "./shared.js";
|
import { getHeaders, closeResponse, isM3UService } from "./shared.js";
|
||||||
|
|
||||||
function toRawHeaders(headers) {
|
function toRawHeaders(headers) {
|
||||||
return Object.entries(headers)
|
return Object.entries(headers)
|
||||||
@ -215,7 +215,7 @@ export function streamVideoOnly(streamInfo, res) {
|
|||||||
args.push('-an')
|
args.push('-an')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (["vimeo", "rutube", "dailymotion"].includes(streamInfo.service)) {
|
if (isM3UService(streamInfo.service)) {
|
||||||
args.push('-bsf:a', 'aac_adtstoasc')
|
args.push('-bsf:a', 'aac_adtstoasc')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user