diff --git a/api/src/misc/utils.js b/api/src/misc/utils.js index 05192d97..34666d1c 100644 --- a/api/src/misc/utils.js +++ b/api/src/misc/utils.js @@ -65,3 +65,14 @@ export function merge(a, b) { return a; } + +export function splitFilenameExtension(filename) { + const parts = filename.split('.'); + const ext = parts.pop(); + + if (!parts.length) { + return [ ext, "" ] + } else { + return [ parts.join('.'), ext ] + } +} diff --git a/api/src/processing/match-action.js b/api/src/processing/match-action.js index 6b5395d4..4fdb24f6 100644 --- a/api/src/processing/match-action.js +++ b/api/src/processing/match-action.js @@ -3,6 +3,7 @@ import createFilename from "./create-filename.js"; import { createResponse } from "./request.js"; import { audioIgnore } from "./service-config.js"; import { createStream } from "../stream/manage.js"; +import { splitFilenameExtension } from "../misc/utils.js"; export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disableMetadata, filenameStyle, twitterGif, requestIP, audioBitrate, alwaysProxy }) { let action, @@ -32,10 +33,11 @@ export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disab } if (action === "muteVideo" && isAudioMuted && !r.filenameAttributes) { - const parts = r.filename.split("."); - const ext = parts.pop(); - - defaultParams.filename = `${parts.join(".")}_mute.${ext}`; + const [ name, ext ] = splitFilenameExtension(r.filename); + defaultParams.filename = `${name}_mute.${ext}`; + } else if (action === "gif") { + const [ name ] = splitFilenameExtension(r.filename); + defaultParams.filename = `${name}.gif`; } switch (action) { diff --git a/api/src/stream/types.js b/api/src/stream/types.js index aa9becf2..184af873 100644 --- a/api/src/stream/types.js +++ b/api/src/stream/types.js @@ -291,7 +291,7 @@ const convertGif = (streamInfo, res) => { const [,,, muxOutput] = process.stdio; res.setHeader('Connection', 'keep-alive'); - res.setHeader('Content-Disposition', contentDisposition(streamInfo.filename.split('.')[0] + ".gif")); + res.setHeader('Content-Disposition', contentDisposition(streamInfo.filename)); pipe(muxOutput, res, shutdown);