api/schema: update youtubeDubLang to accept all valid language codes
This commit is contained in:
parent
b14c618228
commit
cdfc91844d
2 changed files with 7 additions and 11 deletions
|
@ -9,7 +9,6 @@ import match from "../processing/match.js";
|
|||
|
||||
import { env } from "../config.js";
|
||||
import { extract } from "../processing/url.js";
|
||||
import { languageCode } from "../misc/utils.js";
|
||||
import { Bright, Cyan } from "../misc/console-text.js";
|
||||
import { generateHmac, generateSalt } from "../misc/crypto.js";
|
||||
import { randomizeCiphers } from "../misc/randomize-ciphers.js";
|
||||
|
@ -222,16 +221,11 @@ export const runAPI = (express, app, __dirname) => {
|
|||
|
||||
app.post('/', async (req, res) => {
|
||||
const request = req.body;
|
||||
const lang = languageCode(req);
|
||||
|
||||
if (!request.url) {
|
||||
return fail(res, "error.api.link.missing");
|
||||
}
|
||||
|
||||
if (request.youtubeDubBrowserLang) {
|
||||
request.youtubeDubLang = lang;
|
||||
}
|
||||
|
||||
const { success, data: normalizedRequest } = await normalizeRequest(request);
|
||||
if (!success) {
|
||||
return fail(res, "error.api.invalid_body");
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { z } from "zod";
|
||||
|
||||
import { normalizeURL } from "./url.js";
|
||||
import { verifyLanguageCode } from "../misc/utils.js";
|
||||
|
||||
export const apiSchema = z.object({
|
||||
url: z.string()
|
||||
|
@ -33,17 +31,21 @@ export const apiSchema = z.object({
|
|||
).default("1080"),
|
||||
|
||||
youtubeDubLang: z.string()
|
||||
.length(2)
|
||||
.transform(verifyLanguageCode)
|
||||
.min(2)
|
||||
.max(8)
|
||||
.regex(/^[0-9a-zA-Z\-]+$/)
|
||||
.optional(),
|
||||
|
||||
// TODO: remove this variable as it's no longer used
|
||||
// and is kept for schema compatibility reasons
|
||||
youtubeDubBrowserLang: z.boolean().default(false),
|
||||
|
||||
alwaysProxy: z.boolean().default(false),
|
||||
disableMetadata: z.boolean().default(false),
|
||||
tiktokFullAudio: z.boolean().default(false),
|
||||
tiktokH265: z.boolean().default(false),
|
||||
twitterGif: z.boolean().default(true),
|
||||
|
||||
youtubeDubBrowserLang: z.boolean().default(false),
|
||||
youtubeHLS: z.boolean().default(false),
|
||||
})
|
||||
.strict();
|
||||
|
|
Loading…
Reference in a new issue