feat(dl): online track search and add-to-queue utility

This commit is contained in:
2025-10-02 09:54:05 -04:00
parent 81ef5bac90
commit d1edc8b7f7
6 changed files with 115 additions and 94 deletions

View File

@@ -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', {