mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
api: add an option to always proxy files
This commit is contained in:
parent
2f63f6bab7
commit
a9e65b0da0
3 changed files with 8 additions and 1 deletions
|
@ -4,7 +4,7 @@ import { createResponse } from "./request.js";
|
||||||
import { audioIgnore } from "./service-config.js";
|
import { audioIgnore } from "./service-config.js";
|
||||||
import { createStream } from "../stream/manage.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,
|
let action,
|
||||||
responseType = "stream",
|
responseType = "stream",
|
||||||
defaultParams = {
|
defaultParams = {
|
||||||
|
@ -192,5 +192,10 @@ export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disab
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (alwaysProxy && responseType === "redirect") {
|
||||||
|
responseType = "stream";
|
||||||
|
params.type = "proxy";
|
||||||
|
}
|
||||||
|
|
||||||
return createResponse(responseType, {...defaultParams, ...params})
|
return createResponse(responseType, {...defaultParams, ...params})
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,6 +282,7 @@ export default async function(host, patternMatch, obj) {
|
||||||
twitterGif: obj.twitterGif,
|
twitterGif: obj.twitterGif,
|
||||||
requestIP,
|
requestIP,
|
||||||
audioBitrate: obj.audioBitrate,
|
audioBitrate: obj.audioBitrate,
|
||||||
|
alwaysProxy: obj.alwaysProxy,
|
||||||
})
|
})
|
||||||
} catch {
|
} catch {
|
||||||
return createResponse("error", {
|
return createResponse("error", {
|
||||||
|
|
|
@ -37,6 +37,7 @@ export const apiSchema = z.object({
|
||||||
.transform(verifyLanguageCode)
|
.transform(verifyLanguageCode)
|
||||||
.optional(),
|
.optional(),
|
||||||
|
|
||||||
|
alwaysProxy: z.boolean().default(false),
|
||||||
disableMetadata: z.boolean().default(false),
|
disableMetadata: z.boolean().default(false),
|
||||||
tiktokFullAudio: z.boolean().default(true),
|
tiktokFullAudio: z.boolean().default(true),
|
||||||
tiktokH265: z.boolean().default(false),
|
tiktokH265: z.boolean().default(false),
|
||||||
|
|
Loading…
Reference in a new issue