diff --git a/web/discord-embed-proxy.ts b/web/discord-embed-proxy.ts index 2da5eda..68cf8b0 100644 --- a/web/discord-embed-proxy.ts +++ b/web/discord-embed-proxy.ts @@ -15,7 +15,7 @@ const PORT = process.env.PORT || 8080; const DISCORD_USER_AGENT = "Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)"; const VIDEO_USER_AGENT = - "Mozilla/5.0 (Macintosh; Intel Mac OS X 11.6; rv:92.0) Gecko/20100101 Firefox/92.0"; + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0"; const DIR_NAME = path.dirname(fileURLToPath(import.meta.url)); const PROJECT_DIR = path.resolve(DIR_NAME, ".."); @@ -47,7 +47,6 @@ const lock = new AsyncLock(); const EXTENSIONS = ["mp4", "webm", "ogg", "mp3", "wav"] as const; type Extension = (typeof EXTENSIONS)[number]; -const DEFAULT_EXT: Extension = "mp4"; const getChatsoundBuffer = memoizee( async (sentence: string, ext: Extension): Promise => @@ -137,7 +136,25 @@ app.get("/", async (req, res, next) => { userAgent.includes(DISCORD_USER_AGENT) || userAgent.includes(VIDEO_USER_AGENT) ) { - await respondMedia(input, DEFAULT_EXT, res); + const url = `/media.mp4${search || ""}`; + res.type("html"); + res.send(` + + + + + + + + + + + + + + + +`); return; } } @@ -145,6 +162,13 @@ app.get("/", async (req, res, next) => { next(); }); +app.get("/media.mp4", async (req, res) => { + const { search } = url.parse(req.url); + const input = decodeComponent(search?.slice(1) || ""); + + await respondMedia(input, "mp4", res); +}); + app.use(express.static(path.join(PROJECT_DIR, "dist"))); app.listen(PORT, () => {