mirror of
https://github.com/markuryy/shark.git
synced 2025-12-13 12:01:01 +00:00
feat(wip): search
This commit is contained in:
71
src/lib/services/deezer/search.ts
Normal file
71
src/lib/services/deezer/search.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import type { SearchResult } from '$lib/types/search';
|
||||
|
||||
/**
|
||||
* Search Deezer for tracks matching the query
|
||||
* TODO: Implement actual Deezer search API
|
||||
* For now, returns mock data
|
||||
*/
|
||||
export async function searchDeezerTracks(query: string): Promise<SearchResult[]> {
|
||||
if (!query.trim()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Simulate API delay
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
// Mock data - replace with actual Deezer API implementation
|
||||
const mockResults: SearchResult[] = [
|
||||
{
|
||||
title: 'One More Time',
|
||||
artist: 'Daft Punk',
|
||||
album: 'Discovery',
|
||||
duration: 320,
|
||||
source: 'online',
|
||||
trackId: '3135556',
|
||||
coverArtUrl: 'https://e-cdns-images.dzcdn.net/images/cover/2e018122cb56986277102d2041a592c8/250x250-000000-80-0-0.jpg'
|
||||
},
|
||||
{
|
||||
title: 'Get Lucky',
|
||||
artist: 'Daft Punk',
|
||||
album: 'Random Access Memories',
|
||||
duration: 369,
|
||||
source: 'online',
|
||||
trackId: '67238732',
|
||||
coverArtUrl: 'https://e-cdns-images.dzcdn.net/images/cover/b0b1e82769d1a1e452fd3f2f95d3bb0f/250x250-000000-80-0-0.jpg'
|
||||
},
|
||||
{
|
||||
title: 'Around the World',
|
||||
artist: 'Daft Punk',
|
||||
album: 'Homework',
|
||||
duration: 429,
|
||||
source: 'online',
|
||||
trackId: '3135553',
|
||||
coverArtUrl: 'https://e-cdns-images.dzcdn.net/images/cover/d41d8cd98f00b204e9800998ecf8427e/250x250-000000-80-0-0.jpg'
|
||||
},
|
||||
{
|
||||
title: 'Harder, Better, Faster, Stronger',
|
||||
artist: 'Daft Punk',
|
||||
album: 'Discovery',
|
||||
duration: 224,
|
||||
source: 'online',
|
||||
trackId: '3135554',
|
||||
coverArtUrl: 'https://e-cdns-images.dzcdn.net/images/cover/2e018122cb56986277102d2041a592c8/250x250-000000-80-0-0.jpg'
|
||||
},
|
||||
{
|
||||
title: 'Digital Love',
|
||||
artist: 'Daft Punk',
|
||||
album: 'Discovery',
|
||||
duration: 301,
|
||||
source: 'online',
|
||||
trackId: '3135555',
|
||||
coverArtUrl: 'https://e-cdns-images.dzcdn.net/images/cover/2e018122cb56986277102d2041a592c8/250x250-000000-80-0-0.jpg'
|
||||
}
|
||||
];
|
||||
|
||||
// Filter mock results by query
|
||||
return mockResults.filter(result =>
|
||||
result.title.toLowerCase().includes(query.toLowerCase()) ||
|
||||
result.artist.toLowerCase().includes(query.toLowerCase()) ||
|
||||
result.album.toLowerCase().includes(query.toLowerCase())
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user