From a9e65b0da054fb105c4b8803d3b894062893288e Mon Sep 17 00:00:00 2001 From: wukko Date: Sat, 31 Aug 2024 14:07:37 +0600 Subject: [PATCH] api: add an option to always proxy files --- api/src/processing/match-action.js | 7 ++++++- api/src/processing/match.js | 1 + api/src/processing/schema.js | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/api/src/processing/match-action.js b/api/src/processing/match-action.js index 4cc533c4..fa632c99 100644 --- a/api/src/processing/match-action.js +++ b/api/src/processing/match-action.js @@ -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}) } diff --git a/api/src/processing/match.js b/api/src/processing/match.js index 6d7d3422..4d3f7b99 100644 --- a/api/src/processing/match.js +++ b/api/src/processing/match.js @@ -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", { diff --git a/api/src/processing/schema.js b/api/src/processing/schema.js index c7ae1c6e..95167774 100644 --- a/api/src/processing/schema.js +++ b/api/src/processing/schema.js @@ -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),