FileUpload: add video proxy (#1005)

This commit is contained in:
Key 2026-04-21 21:09:43 +01:00 • committed by GitHub
parent 4e8e802cc7
commit a18e75dae6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 10 deletions

View file

@ -40,9 +40,8 @@ const litterboxOptions = [
]; ];
const embedProxyOptions = [ const embedProxyOptions = [
{ label: "x266.mov", value: "x266", default: true }, { label: "CORS Proxy", value: "cors", default: true },
{ label: "discord.nfp.is", value: "nfp" }, { label: "discord.nfp.is", value: "nfp" }
{ label: "embeddr.top", value: "embeddr" }
]; ];
export const settings = definePluginSettings({ export const settings = definePluginSettings({
@ -213,7 +212,7 @@ export const settings = definePluginSettings({
type: OptionType.SELECT, type: OptionType.SELECT,
description: "Embed helper service to wrap uploaded video links.", description: "Embed helper service to wrap uploaded video links.",
options: embedProxyOptions, options: embedProxyOptions,
default: "x266", default: "cors",
hidden: true hidden: true
}, },
corsProxyUrl: { corsProxyUrl: {

View file

@ -38,7 +38,7 @@ function toProxyUrl(url: string): string {
let isUploading = false; let isUploading = false;
type UploadPhase = "idle" | "preparing" | "uploading" | "retrying" | "success" | "failed" | "cancelled"; type UploadPhase = "idle" | "preparing" | "uploading" | "retrying" | "success" | "failed" | "cancelled";
type EmbedProxyService = "x266" | "nfp" | "embeddr"; type EmbedProxyService = "cors" | "nfp";
export interface UploadProgressState { export interface UploadProgressState {
phase: UploadPhase; phase: UploadPhase;
@ -699,7 +699,7 @@ const EXE_BLOCKED_SERVICES = new Set<ServiceType>([
function getEmbedProxyService(): EmbedProxyService { function getEmbedProxyService(): EmbedProxyService {
const service = settings.store.embedProxyService; const service = settings.store.embedProxyService;
return service === "nfp" || service === "embeddr" ? service : "x266" return service === "nfp" ? service : "cors";
} }
@ -723,13 +723,12 @@ function applyEmbedProxy(url: string): string {
} }
switch (service) { switch (service) {
case "x266": case "cors":
return `https://x266.mov/e/${url}`; return toProxyUrl(url);
case "nfp": case "nfp":
return `https://discord.nfp.is/?v=${encodeURIComponent(url)}`; return `https://discord.nfp.is/?v=${encodeURIComponent(url)}`;
case "embeddr":
default: default:
return `https://embeddr.top/${url}`; return toProxyUrl(url);
} }
} }