mirror of
https://github.com/wukko/cobalt.git
synced 2024-09-30 07:09:58 +01: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) {
|
export function apiJSON(type, obj) {
|
||||||
try {
|
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) {
|
switch (type) {
|
||||||
case 0:
|
case 0:
|
||||||
return { status: 400, body: { status: "error", text: obj.t } };
|
return { status: 400, body: { status: "error", text: obj.t } };
|
||||||
case 1:
|
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:
|
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:
|
case 3:
|
||||||
return { status: 200, body: { status: "success", text: obj.t } };
|
return { status: 200, body: { status: "success", text: obj.t } };
|
||||||
case 4:
|
case 4:
|
||||||
|
|
Loading…
Reference in a new issue