Files
amaoke.app/src/routes/song/[id]/play/+page.server.ts
T
2025-11-23 10:09:37 +08:00

14 lines
559 B
TypeScript

import type { PageServerLoad } from './$types'
import { getLyricsProcessed, getSongUrl, checkLyricsProcessed } from "$lib/server/songs.ts"
import { redirect } from '@sveltejs/kit'
export const load: PageServerLoad = async ({ params, url }) => {
const songId = +params.id
const hasLrc = await checkLyricsProcessed(songId)
if (!hasLrc) throw redirect(302, `/song/${songId}`)
const lrc = await getLyricsProcessed(songId)!
const audioUrl = url.searchParams.get('music') === 'true' ? await getSongUrl(songId) : undefined
return { lrc, audioUrl }
}