mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-10 15:28:29 +00:00
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
This commit is contained in:
parent
e8113a83de
commit
58ea4aed01
@ -148,7 +148,14 @@ export default async function(obj) {
|
|||||||
|
|
||||||
let cover;
|
let cover;
|
||||||
if (json.artwork_url) {
|
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 {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user