api: add an option to always proxy files

This commit is contained in:
wukko 2024-08-31 14:07:37 +06:00
parent 2f63f6bab7
commit a9e65b0da0
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
3 changed files with 8 additions and 1 deletions

View file

@ -4,7 +4,7 @@ import { createResponse } from "./request.js";
import { audioIgnore } from "./service-config.js";
import { createStream } from "../stream/manage.js";
export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disableMetadata, filenameStyle, twitterGif, requestIP, audioBitrate }) {
export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disableMetadata, filenameStyle, twitterGif, requestIP, audioBitrate, alwaysProxy }) {
let action,
responseType = "stream",
defaultParams = {
@ -192,5 +192,10 @@ export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disab
break;
}
if (alwaysProxy && responseType === "redirect") {
responseType = "stream";
params.type = "proxy";
}
return createResponse(responseType, {...defaultParams, ...params})
}

View file

@ -282,6 +282,7 @@ export default async function(host, patternMatch, obj) {
twitterGif: obj.twitterGif,
requestIP,
audioBitrate: obj.audioBitrate,
alwaysProxy: obj.alwaysProxy,
})
} catch {
return createResponse("error", {

View file

@ -37,6 +37,7 @@ export const apiSchema = z.object({
.transform(verifyLanguageCode)
.optional(),
alwaysProxy: z.boolean().default(false),
disableMetadata: z.boolean().default(false),
tiktokFullAudio: z.boolean().default(true),
tiktokH265: z.boolean().default(false),