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

@@ -4,7 +4,8 @@
import SearchResultsTable from '$lib/components/SearchResultsTable.svelte';
import { searchLocalTracks } from '$lib/library/search';
import { searchDeezerTracks } from '$lib/services/deezer/search';
import { downloadTrack } from '$lib/services/deezer/downloader';
import { deezerAPI } from '$lib/services/deezer';
import { addDeezerTrackToQueue } from '$lib/services/deezer/addToQueue';
import { settings, loadSettings } from '$lib/stores/settings';
import { deezerAuth } from '$lib/stores/deezer';
import type { SearchResult, SearchType } from '$lib/types/search';
@@ -69,7 +70,7 @@
return;
}
if (!$deezerAuth.user) {
if (!$deezerAuth.arl || !$deezerAuth.user) {
error = 'Please log in to Deezer first (Services → Deezer)';
return;
}
@@ -80,11 +81,12 @@
}
try {
console.log('Downloading track:', result.trackId);
await downloadTrack(result.trackId);
// TODO: Show success notification
deezerAPI.setArl($deezerAuth.arl);
await addDeezerTrackToQueue(result.trackId);
error = null; // Clear any previous error
} catch (e) {
error = 'Error downloading track: ' + (e as Error).message;
console.error('Queue error:', e);
error = 'Error adding to download queue: ' + (e as Error).message;
}
}
</script>