mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 03:08:30 +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 { 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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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')
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user