chore: update some more artist data

This commit is contained in:
Cory Dransfeldt 2024-03-19 14:46:54 -07:00
parent 970c5318b7
commit 95e95861bf
No known key found for this signature in database
4 changed files with 26 additions and 5 deletions

View file

@ -123,11 +123,21 @@ export default async () => {
console.log(err);
return {}
});
const artistCapitalzationRes = await fetch("https://coryd.dev/api/artist-capitalization", {
type: "json",
}).then((data) => {
if (data.ok) return data.json()
throw new Error('Something went wrong with the artist capitalization endpoint.');
}).catch(err => {
console.log(err);
return {}
});
const track = trackRes["recenttracks"]["track"][0];
const artist = track["artist"]["#text"];
const artist = artistCapitalization(track["artist"]["#text"]);
let mbid = track["artist"]["mbid"];
let genre = "";
let genre = '';
const mbidMap = (artist) => mbidRes[artist.toLowerCase()] || "";
const artistCapitalization = (artist) => artistCapitalzationRes[artist?.toLowerCase()] || artist
// mbid mismatches
if (mbidMap(artist) !== "") mbid = mbidMap(artist);
@ -162,9 +172,9 @@ export default async () => {
return new Response(JSON.stringify({
content: `${emojiMap(
genre,
track["artist"]["#text"]
artist
)} <a href="${trackUrl}">${track["name"]}</a> by <a href="${artistUrl}">${
track["artist"]["#text"]
artist
}</a>`,
}),
{ headers }

View file

@ -1,6 +1,6 @@
{
"name": "coryd.dev",
"version": "8.3.6",
"version": "8.3.7",
"description": "The source for my personal site. Built using 11ty.",
"type": "module",
"scripts": {

View file

@ -0,0 +1,5 @@
import artistCapitalizationPatches from './json/artist-capitalization-patches.js';
export default async function () {
return artistCapitalizationPatches
}

View file

@ -0,0 +1,6 @@
---
layout: null
eleventyExcludeFromCollections: true
permalink: /api/artist-capitalization
---
{{ artistCapitalization | json }}