31 lines
756 B
TypeScript
31 lines
756 B
TypeScript
import { NextResponse } from 'next/server'
|
|
import { navidromeGet } from '@/lib/navidrome'
|
|
|
|
interface LyricsResult {
|
|
lyrics?: {
|
|
artist?: string
|
|
title?: string
|
|
value?: string
|
|
}
|
|
}
|
|
|
|
export async function GET(request: Request) {
|
|
const { searchParams } = new URL(request.url)
|
|
const artist = searchParams.get('artist') || ''
|
|
const title = searchParams.get('title') || ''
|
|
|
|
if (!artist || !title) {
|
|
return NextResponse.json({ lyrics: null })
|
|
}
|
|
|
|
try {
|
|
const data = await navidromeGet<LyricsResult>('getLyrics.view', { artist, title })
|
|
return NextResponse.json({
|
|
lyrics: data.lyrics?.value || null,
|
|
})
|
|
} catch (error) {
|
|
console.error('Lyrics error:', error)
|
|
return NextResponse.json({ lyrics: null })
|
|
}
|
|
}
|