mirror of
https://github.com/markuryy/shark.git
synced 2025-12-13 03:51:02 +00:00
feat(dl): online track search and add-to-queue utility
This commit is contained in:
@@ -250,6 +250,35 @@ export class DeezerAPI {
|
||||
return this.apiCall('song.getData', { SNG_ID: trackId });
|
||||
}
|
||||
|
||||
// Search tracks using public API (no authentication required)
|
||||
async searchTracks(query: string, limit: number = 25): Promise<any> {
|
||||
const url = `https://api.deezer.com/search/track?q=${encodeURIComponent(query)}&limit=${limit}`;
|
||||
|
||||
console.log('[DEBUG] Searching Deezer API:', { query, limit, url });
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
...this.httpHeaders
|
||||
},
|
||||
connectTimeout: 30000
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
console.log('[DEBUG] Search results:', result);
|
||||
|
||||
return result;
|
||||
} catch (error: any) {
|
||||
console.error('[ERROR] Search failed:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Get playlist data
|
||||
async getPlaylist(playlistId: string): Promise<any> {
|
||||
return this.apiCall('deezer.pagePlaylist', {
|
||||
|
||||
Reference in New Issue
Block a user