Compare commits
1 Commits
5730d6a5ac
...
7134437e00
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7134437e00 |
@@ -40,14 +40,20 @@ export async function itunes_cover_url(artist: string, album: string) {
|
|||||||
.replace(/[-_,"':;|]/g, " ")
|
.replace(/[-_,"':;|]/g, " ")
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
|
|
||||||
const apple_music_results = await fetch("https://itunes.apple.com/search", {
|
const response = await fetch("https://itunes.apple.com/search", {
|
||||||
body: new URLSearchParams({
|
body: new URLSearchParams({
|
||||||
term: query,
|
term: query,
|
||||||
entity: "song",
|
entity: "song",
|
||||||
limit: "10",
|
limit: "10",
|
||||||
}),
|
}),
|
||||||
method: "POST",
|
method: "POST",
|
||||||
}).then((res) => res.json());
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`iTunes API failed with status ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const apple_music_results = await response.json();
|
||||||
|
|
||||||
for (let result of apple_music_results.results) {
|
for (let result of apple_music_results.results) {
|
||||||
if (artist == result.artistName.toLowerCase()) {
|
if (artist == result.artistName.toLowerCase()) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ app.get("/cover/:artist/:album/:id", ({ params: { artist, album, id } }) =>
|
|||||||
get_image_from_server(artist, album, id),
|
get_image_from_server(artist, album, id),
|
||||||
);
|
);
|
||||||
|
|
||||||
app.listen({ hostname: '0.0.0.0', port: 3000 }, ({ hostname, port }) => {
|
app.listen({ hostname: "0.0.0.0", port: 3000 }, ({ hostname, port }) => {
|
||||||
console.log(`🦊 Elysia is running at ${hostname}:${port}`);
|
console.log(`🦊 Elysia is running at ${hostname}:${port}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ async function get_image_from_server(
|
|||||||
first_error,
|
first_error,
|
||||||
secong_error,
|
secong_error,
|
||||||
);
|
);
|
||||||
throw Error("cover not found");
|
return new Response("Cover not found", { status: 404 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user