chore: statically populate now playing
This commit is contained in:
parent
1880790c05
commit
212745f52d
4 changed files with 36 additions and 4 deletions
33
src/data/nowPlaying.js
Normal file
33
src/data/nowPlaying.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const SUPABASE_URL = process.env.SUPABASE_URL
|
||||
const SUPABASE_KEY = process.env.SUPABASE_KEY
|
||||
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY)
|
||||
|
||||
const fetchNowPlaying = async () => {
|
||||
const { data, error } = await supabase
|
||||
.from('optimized_latest_listen')
|
||||
.select('*')
|
||||
.single()
|
||||
|
||||
if (error) {
|
||||
console.error('Error fetching the latest track:', error)
|
||||
return {}
|
||||
}
|
||||
|
||||
const genreEmoji = data.genre_emoji
|
||||
const emoji = data.artist_emoji || genreEmoji
|
||||
|
||||
return {
|
||||
content: `${emoji || '🎧'} ${data.track_name} by <a href="https://coryd.dev${data.url}">${data.artist_name}</a>`,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function () {
|
||||
try {
|
||||
return await fetchNowPlaying()
|
||||
} catch (error) {
|
||||
console.error('Error fetching and processing now-playing data:', error)
|
||||
return {}
|
||||
}
|
||||
}
|
Reference in a new issue