Skip to content

Commit 38d5d02

Browse files
committed
newgrounds: return proper error codes
1 parent 985bedf commit 38d5d02

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: api/src/processing/services/newgrounds.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ async function getVideo(obj) {
7171
.then(request => request.text())
7272
.catch(() => {});
7373

74-
if (!req) return { error: 'ErrorCouldntFetch' };
74+
if (!req) return { error: 'fetch.fail' };
7575

7676
let json;
7777
try {
7878
json = JSON.parse(req);
79-
} catch { return { error: 'ErrorEmptyDownload' }; }
79+
} catch { return { error: 'fetch.empty' }; }
8080

8181
const videoData = getQuality(json.sources, obj.quality);
8282
if (videoData == null) {
83-
return { error: 'ErrorCouldntFetch' };
83+
return { error: 'fetch.empty' };
8484
}
8585
if (!videoData.type.includes('mp4')) {
86-
return { error: 'ErrorCouldntFetch' };
86+
return { error: 'fetch.empty' };
8787
}
8888

8989
let fileMetadata = {
@@ -115,14 +115,14 @@ async function getMusic(obj) {
115115
.then(request => request.text())
116116
.catch(() => {});
117117

118-
if (!req) return { error: 'ErrorCouldntFetch' };
118+
if (!req) return { error: 'fetch.fail' };
119119

120120
const titleMatch = req.match(/"name"\s*:\s*"([^"]+)"/);
121121
const artistMatch = req.match(/"artist"\s*:\s*"([^"]+)"/);
122122
const urlMatch = req.match(/"filename"\s*:\s*"([^"]+)"/);
123123

124124
if (!titleMatch || !artistMatch || !urlMatch) {
125-
return { error: 'ErrorCouldntFetch' };
125+
return { error: 'fetch.empty' };
126126
}
127127

128128
const title = titleMatch[1];
@@ -153,5 +153,5 @@ export default function(obj) {
153153
if (obj.type == 'audio') {
154154
return getMusic(obj);
155155
}
156-
return { error: 'ErrorUnsupported' };
156+
return { error: 'link.unsupported' };
157157
}

0 commit comments

Comments
 (0)