Skip to content

best way to save what you love

api/soundcloud: check if a cover url returns 200

wukko58ea4aed0138
diff --git a/api/src/processing/services/soundcloud.js b/api/src/processing/services/soundcloud.js
index 1c04a366..a73e6474 100644
--- a/api/src/processing/services/soundcloud.js
+++ b/api/src/processing/services/soundcloud.js
@@ -148,7 +148,14 @@ export default async function(obj) {
let cover;
if (json.artwork_url) {
- cover = json.artwork_url.replace(/-large/, "-t1080x1080");
+ const coverUrl = json.artwork_url.replace(/-large/, "-t1080x1080");
+ const testCover = await fetch(coverUrl)
+ .then(r => r.status === 200)
+ .catch(() => {});
+
+ if (testCover) {
+ cover = coverUrl;
+ }
}
return {