New features: - YouTube search integration with live results - Smart input detection (URL vs search query) - Real-time search with thumbnails and metadata - Fixed progress bar not advancing for single songs Technical improvements: - Added searchYoutube function to ytdlp.ts - Created /api/search endpoint - Enhanced Header component with search UI - Fixed PlayerBar useEffect dependencies
20 lines
599 B
TypeScript
20 lines
599 B
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import { searchYoutube } from '@/lib/ytdlp'
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const { searchParams } = new URL(request.url)
|
|
const query = searchParams.get('q')
|
|
|
|
if (!query) {
|
|
return NextResponse.json({ error: 'Query parameter is required' }, { status: 400 })
|
|
}
|
|
|
|
const results = await searchYoutube(query, 10)
|
|
return NextResponse.json(results)
|
|
} catch (error) {
|
|
console.error('Search error:', error)
|
|
return NextResponse.json({ error: 'Failed to search' }, { status: 500 })
|
|
}
|
|
}
|