Skip to content

Commit 58ea4ae

Browse files
committed
api/soundcloud: check if a cover url returns 200
some songs don't have a cover but artwork_url is still defined, even though the response is always 404
1 parent e8113a8 commit 58ea4ae

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

api/src/processing/services/soundcloud.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,14 @@ export default async function(obj) {
148148

149149
let cover;
150150
if (json.artwork_url) {
151-
cover = json.artwork_url.replace(/-large/, "-t1080x1080");
151+
const coverUrl = json.artwork_url.replace(/-large/, "-t1080x1080");
152+
const testCover = await fetch(coverUrl)
153+
.then(r => r.status === 200)
154+
.catch(() => {});
155+
156+
if (testCover) {
157+
cover = coverUrl;
158+
}
152159
}
153160

154161
return {

0 commit comments

Comments
 (0)