feat: remove emoji from the client

This commit is contained in:
Cory Dransfeldt 2024-06-02 10:37:48 -07:00
parent ae19cb4618
commit cc2ca7d134
No known key found for this signature in database
3 changed files with 9 additions and 91 deletions

View file

@ -30,90 +30,10 @@ const parseCountryField = (countryField) => {
return countries.map(getCountryName).join(', ') return countries.map(getCountryName).join(', ')
} }
const emojiMap = (genre, artist) => {
const DEFAULT = "🎧"
const normalizedArtist = artist?.toLowerCase()
if (normalizedArtist === "afi") return "⛵️🌅"
if (normalizedArtist === "agalloch") return "🏔️"
if (normalizedArtist === "american football") return "🏠"
if (normalizedArtist === "augury") return "☄️"
if (normalizedArtist === "autopsy") return "🧟"
if (normalizedArtist === "bad religion") return "🚫✝️"
if (normalizedArtist === "balance and composure") return "🪂"
if (normalizedArtist === "bedsore") return "🛏️"
if (normalizedArtist === "birds in row") return "🦅🦉🦢"
if (normalizedArtist === "black flag") return "🏴"
if (normalizedArtist === "blink-182") return "😵"
if (normalizedArtist === "blood incantation") return "👽"
if (normalizedArtist === "bolt thrower") return "⚔️"
if (normalizedArtist === "bruce springsteen") return "🇺🇸"
if (normalizedArtist === "carcass") return "🥼"
if (normalizedArtist === "cloud rat") return "☁️🐀"
if (normalizedArtist === "counting crows") return "🐦‍⬛"
if (normalizedArtist === "david bowie") return "👨🏻‍🎤"
if (normalizedArtist === "devoid of thought") return "🚫💭"
if (normalizedArtist === "deftones") return "🦉"
if (normalizedArtist === "drug church") return "💊⛪️"
if (normalizedArtist === "fleshwater") return "🐤"
if (normalizedArtist === "full of hell & nothing") return "🫨🎸"
if (normalizedArtist === "imperial triumphant") return "🎭"
if (normalizedArtist === "mastodon") return "🐋"
if (normalizedArtist === "mineral") return "🪨"
if (normalizedArtist === "minor threat") return "👨🏻‍🦲"
if (normalizedArtist === "nomeansno") return "🐵🐮🚬"
if (normalizedArtist === "nothing") return "🏳️"
if (normalizedArtist === "panopticon") return "🪕🪦"
if (normalizedArtist === "plunger") return "🪠"
if (normalizedArtist === "radiohead") return "📻"
if (normalizedArtist === "soccer mommy") return "⚽️"
if (normalizedArtist === "taylor swift") return "👸🏼"
if (normalizedArtist === "the mars volta") return "💡😮"
if (normalizedArtist === "thrice") return "👨‍🎨🚑"
if (normalizedArtist === "tom waits") return "🤹🏻"
if (normalizedArtist === "webbed wing") return "🤡"
// early return for bad input
if (!genre) return DEFAULT
if (genre.includes("death metal") || genre.includes("death-doom")) return "💀"
if (genre.includes("black metal") || genre.includes("blackgaze")) return "🪦"
if (genre.includes("metal")) return "🤘"
if (genre.includes("emo") || genre.includes("blues")) return "😢"
if (genre.includes("grind") || genre.includes("powerviolence")) return "🫨"
if (
genre.includes("country") ||
genre.includes("americana") ||
genre.includes("bluegrass") ||
genre.includes("folk") ||
genre.includes("songwriter")
)
return "🪕"
if (genre.includes("post-punk")) return "😔"
if (genre.includes("dance-punk")) return "🪩"
if (genre.includes("punk") || genre.includes("hardcore")) return "✊"
if (genre.includes("hip hop")) return "🎤"
if (genre.includes("hip-hop")) return "🎤"
if (genre.includes("progressive") || genre.includes("experimental"))
return "🤓"
if (genre.includes("jazz")) return "🎺"
if (genre.includes("psychedelic")) return "💊"
if (genre.includes("dance") || genre.includes("electronic")) return "💻"
if (genre.includes("ambient")) return "🤫"
if (
genre.includes("alternative") ||
genre.includes("rock") ||
genre.includes("shoegaze") ||
genre.includes("screamo") ||
genre.includes("grunge")
)
return "🎸"
return DEFAULT
}
const fetchGenreById = async (genreId) => { const fetchGenreById = async (genreId) => {
const { data, error } = await supabase const { data, error } = await supabase
.from('genres') .from('genres')
.select('name') .select('emoji')
.eq('id', genreId) .eq('id', genreId)
.single() .single()
@ -122,7 +42,7 @@ const fetchGenreById = async (genreId) => {
return null return null
} }
return data.name return data.emoji
} }
export default async () => { export default async () => {
@ -132,7 +52,7 @@ export default async () => {
track_name, track_name,
artist_name, artist_name,
listened_at, listened_at,
artists (mbid, genres, country) artists (mbid, genres, country, emoji)
`) `)
.order('listened_at', { ascending: false }) .order('listened_at', { ascending: false })
.range(0, 1) .range(0, 1)
@ -152,13 +72,11 @@ export default async () => {
} }
const scrobbleData = data[0] const scrobbleData = data[0]
scrobbleData.genre = await fetchGenreById(data[0].artists.genres) const genreEmoji = await fetchGenreById(data[0].artists.genres)
const emoji = scrobbleData.artists.emoji || genreEmoji
return new Response(JSON.stringify({ return new Response(JSON.stringify({
content: `${emojiMap( content: `${emoji || '🎧'} ${scrobbleData.track_name} by <a href="https://coryd.dev/music/artists/${sanitizeMediaString(scrobbleData.artist_name)}-${sanitizeMediaString(parseCountryField(scrobbleData.artists.country))}">${
scrobbleData.genre,
scrobbleData.artist_name
)} ${scrobbleData.track_name} by <a href="https://coryd.dev/music/artists/${sanitizeMediaString(scrobbleData.artist_name)}-${sanitizeMediaString(parseCountryField(scrobbleData.artists.country))}">${
scrobbleData.artist_name scrobbleData.artist_name
}</a>`, }</a>`,
}), { headers }); }), { headers });

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "coryd.dev", "name": "coryd.dev",
"version": "18.1.4", "version": "18.2.4",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "coryd.dev", "name": "coryd.dev",
"version": "18.1.4", "version": "18.2.4",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@cdransf/api-text": "^1.4.0", "@cdransf/api-text": "^1.4.0",

View file

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