From 38d5d029387c94f7d5f222efc88656ff00c06e38 Mon Sep 17 00:00:00 2001 From: hyperdefined Date: Wed, 11 Sep 2024 12:21:59 -0400 Subject: [PATCH] newgrounds: return proper error codes --- api/src/processing/services/newgrounds.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api/src/processing/services/newgrounds.js b/api/src/processing/services/newgrounds.js index e7ee2228..9475bd97 100644 --- a/api/src/processing/services/newgrounds.js +++ b/api/src/processing/services/newgrounds.js @@ -71,19 +71,19 @@ async function getVideo(obj) { .then(request => request.text()) .catch(() => {}); - if (!req) return { error: 'ErrorCouldntFetch' }; + if (!req) return { error: 'fetch.fail' }; let json; try { json = JSON.parse(req); - } catch { return { error: 'ErrorEmptyDownload' }; } + } catch { return { error: 'fetch.empty' }; } const videoData = getQuality(json.sources, obj.quality); if (videoData == null) { - return { error: 'ErrorCouldntFetch' }; + return { error: 'fetch.empty' }; } if (!videoData.type.includes('mp4')) { - return { error: 'ErrorCouldntFetch' }; + return { error: 'fetch.empty' }; } let fileMetadata = { @@ -115,14 +115,14 @@ async function getMusic(obj) { .then(request => request.text()) .catch(() => {}); - if (!req) return { error: 'ErrorCouldntFetch' }; + if (!req) return { error: 'fetch.fail' }; const titleMatch = req.match(/"name"\s*:\s*"([^"]+)"/); const artistMatch = req.match(/"artist"\s*:\s*"([^"]+)"/); const urlMatch = req.match(/"filename"\s*:\s*"([^"]+)"/); if (!titleMatch || !artistMatch || !urlMatch) { - return { error: 'ErrorCouldntFetch' }; + return { error: 'fetch.empty' }; } const title = titleMatch[1]; @@ -153,5 +153,5 @@ export default function(obj) { if (obj.type == 'audio') { return getMusic(obj); } - return { error: 'ErrorUnsupported' }; + return { error: 'link.unsupported' }; } \ No newline at end of file