api: allow passing headers from service handler

This commit is contained in:
dumbmoron 2024-05-22 17:50:44 +00:00
parent 3197cee473
commit 6f016e7c29
No known key found for this signature in database
3 changed files with 9 additions and 2 deletions

View File

@ -192,7 +192,10 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) {
const streamInfo = getInternalStream(req.query.id);
if (!streamInfo) return res.sendStatus(404);
streamInfo.headers = req.headers;
streamInfo.headers = {
...req.headers,
...streamInfo.headers
};
return stream(res, { type: 'internal', ...streamInfo });
} catch {

View File

@ -9,6 +9,7 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di
responseType = "stream",
defaultParams = {
u: r.urls,
headers: r.headers,
service: host,
filename: r.filenameAttributes ?
createFilename(r.filenameAttributes, filenamePattern, isAudioOnly, isAudioMuted) : r.filename,
@ -80,6 +81,7 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di
service: "tiktok",
type: audioStreamType,
u: r.urls,
headers: r.headers,
filename: r.audioFilename,
isAudioOnly: true,
audioFormat,

View File

@ -38,6 +38,7 @@ export function createStream(obj) {
filename: obj.filename,
audioFormat: obj.audioFormat,
isAudioOnly: !!obj.isAudioOnly,
headers: obj.headers,
copy: !!obj.copy,
mute: !!obj.mute,
metadata: obj.fileMetadata || false,
@ -82,6 +83,7 @@ export function createInternalStream(url, obj = {}) {
internalStreamCache[streamID] = {
url,
service: obj.service,
headers: obj.headers,
controller: new AbortController(),
dispatcher
};