From ecf2dac5d8b932d80f2dcb9f9fdb81fdcbc50538 Mon Sep 17 00:00:00 2001 From: wukko Date: Sun, 4 Sep 2022 10:14:25 +0600 Subject: [PATCH] fixed a silly mistake that broke soundcloud also added an error handler for this issue if it happens ever again --- src/cobalt.js | 6 +++++- src/modules/match.js | 1 + src/modules/sub/matchActionDecider.js | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cobalt.js b/src/cobalt.js index 87ba5d2..866c6b9 100644 --- a/src/cobalt.js +++ b/src/cobalt.js @@ -73,7 +73,11 @@ if (fs.existsSync('./.env')) { res.status(j.status).json(j.body); } else { let j = apiJSON(3, { t: loc(languageCode(req), 'ErrorNoLink', process.env.selfURL) }) - res.status(j.status).json(j.body); + if (!j === undefined && j.status && j.body) { + res.status(j.status).json(j.body); + } else { + res.status(500).json({ 'status': 'error', 'text': loc(languageCode(req), 'ErrorUnknownStatus') }) + } } break; case 'stream': diff --git a/src/modules/match.js b/src/modules/match.js index 3f48a96..4b9b803 100644 --- a/src/modules/match.js +++ b/src/modules/match.js @@ -76,6 +76,7 @@ export default async function (host, patternMatch, url, lang, obj) { noWatermark: obj.noWatermark, fullAudio: obj.fullAudio, isAudioOnly: obj.isAudioOnly }); + if (r.isAudioOnly) obj.isAudioOnly = true break; case "tumblr": r = await tumblr({ diff --git a/src/modules/sub/matchActionDecider.js b/src/modules/sub/matchActionDecider.js index 7f3a113..23f47a9 100644 --- a/src/modules/sub/matchActionDecider.js +++ b/src/modules/sub/matchActionDecider.js @@ -1,9 +1,9 @@ import { audioIgnore, services, supportedAudio } from "../config.js" import { apiJSON } from "./utils.js" -export default function(r, host, ip, audioFormat) { +export default function(r, host, ip, audioFormat, isAudioOnly) { if (!r.error) { - if (!r.isAudioOnly) { + if (!isAudioOnly) { switch (host) { case "twitter": return apiJSON(1, { u: r.urls }) @@ -51,7 +51,7 @@ export default function(r, host, ip, audioFormat) { let copy = false; if (!supportedAudio.includes(audioFormat)) audioFormat = "best"; - if ((host == "tiktok" || host == "douyin") && r.isAudioOnly && services.tiktok.audioFormats.includes(audioFormat)) { + if ((host == "tiktok" || host == "douyin") && isAudioOnly && services.tiktok.audioFormats.includes(audioFormat)) { if (r.isMp3) { if (audioFormat == "mp3" || audioFormat == "best") { audioFormat = "mp3"