mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-16 05:09:57 +00:00
Add .mp3 extension to audio without extension, include filename in response
This commit is contained in:
parent
b1adbd659e
commit
25f2a015c5
1 changed files with 11 additions and 2 deletions
|
@ -15,13 +15,22 @@ const forbiddenCharsString = ['}', '{', '%', '>', '<', '^', ';', '`', '$', '"',
|
|||
|
||||
export function apiJSON(type, obj) {
|
||||
try {
|
||||
try {
|
||||
var filename = obj.filename;
|
||||
if (obj.isAudioOnly == true && typeof filename == 'string' && !filename.endsWith(".mp3") && !filename.endsWith(".ogg") && !filename.endsWith(".wav") && !filename.endsWith(".opus")) {
|
||||
obj.filename = filename + '.mp3';
|
||||
}
|
||||
} catch (e) {
|
||||
return { status: 500, body: { status: "error", text: "Internal Server Error", critical: true } };
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case 0:
|
||||
return { status: 400, body: { status: "error", text: obj.t } };
|
||||
case 1:
|
||||
return { status: 200, body: { status: "redirect", url: obj.u } };
|
||||
return { status: 200, body: { status: "redirect", url: obj.u, filename: obj.filename } };
|
||||
case 2:
|
||||
return { status: 200, body: { status: "stream", url: createStream(obj) } };
|
||||
return { status: 200, body: { status: "stream", url: createStream(obj), filename: obj.filename } };
|
||||
case 3:
|
||||
return { status: 200, body: { status: "success", text: obj.t } };
|
||||
case 4:
|
||||
|
|
Loading…
Reference in a new issue