api: return correct extension for gif downloads in api response
This commit is contained in:
parent
29f967a3ec
commit
d560c0d34a
3 changed files with 18 additions and 5 deletions
|
@ -65,3 +65,14 @@ export function merge(a, b) {
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function splitFilenameExtension(filename) {
|
||||||
|
const parts = filename.split('.');
|
||||||
|
const ext = parts.pop();
|
||||||
|
|
||||||
|
if (!parts.length) {
|
||||||
|
return [ ext, "" ]
|
||||||
|
} else {
|
||||||
|
return [ parts.join('.'), ext ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import createFilename from "./create-filename.js";
|
||||||
import { createResponse } from "./request.js";
|
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";
|
||||||
|
import { splitFilenameExtension } from "../misc/utils.js";
|
||||||
|
|
||||||
export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disableMetadata, filenameStyle, twitterGif, requestIP, audioBitrate, alwaysProxy }) {
|
export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disableMetadata, filenameStyle, twitterGif, requestIP, audioBitrate, alwaysProxy }) {
|
||||||
let action,
|
let action,
|
||||||
|
@ -32,10 +33,11 @@ export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disab
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action === "muteVideo" && isAudioMuted && !r.filenameAttributes) {
|
if (action === "muteVideo" && isAudioMuted && !r.filenameAttributes) {
|
||||||
const parts = r.filename.split(".");
|
const [ name, ext ] = splitFilenameExtension(r.filename);
|
||||||
const ext = parts.pop();
|
defaultParams.filename = `${name}_mute.${ext}`;
|
||||||
|
} else if (action === "gif") {
|
||||||
defaultParams.filename = `${parts.join(".")}_mute.${ext}`;
|
const [ name ] = splitFilenameExtension(r.filename);
|
||||||
|
defaultParams.filename = `${name}.gif`;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
|
|
@ -291,7 +291,7 @@ const convertGif = (streamInfo, res) => {
|
||||||
const [,,, muxOutput] = process.stdio;
|
const [,,, muxOutput] = process.stdio;
|
||||||
|
|
||||||
res.setHeader('Connection', 'keep-alive');
|
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);
|
pipe(muxOutput, res, shutdown);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue