feat(dz): add playlist download, existence check, and improved queue handling

Add ability to download entire playlists as M3U8 files, with UI
integration and per-track download actions. Implement track existence
checking to avoid duplicate downloads, respecting the overwrite setting.
Improve queue manager to sync downloaded tracks to the library
incrementally. Refactor playlist parsing and metadata reading to use the
Rust backend for better performance and accuracy. Update UI to reflect
track existence and download status in playlist views.

BREAKING CHANGE: Deezer playlist and track download logic now relies on
Rust backend for metadata and new existence checking; some APIs and
internal behaviors have changed.
This commit is contained in:
2025-10-02 19:26:12 -04:00
parent 40e72126aa
commit e1e7817c71
17 changed files with 1341 additions and 332 deletions

View File

@@ -13,6 +13,8 @@ import {
type QueueItem
} from '$lib/stores/downloadQueue';
import { settings } from '$lib/stores/settings';
import { deezerAuth } from '$lib/stores/deezer';
import { syncTrackPaths } from '$lib/library/incrementalSync';
import { get } from 'svelte/store';
import type { DeezerTrack } from '$lib/types/deezer';
@@ -121,6 +123,13 @@ export class DeezerQueueManager {
throw new Error('Music folder not configured');
}
// Set ARL for authentication
const authState = get(deezerAuth);
if (!authState.arl) {
throw new Error('Deezer ARL not found - please log in');
}
deezerAPI.setArl(authState.arl);
// Get user data for license token
const userData = await deezerAPI.getUserData();
const licenseToken = userData.USER?.OPTIONS?.license_token;
@@ -169,6 +178,14 @@ export class DeezerQueueManager {
);
console.log(`[DeezerQueueManager] Downloaded: ${filePath}`);
// Trigger incremental library sync for this track
try {
await syncTrackPaths([filePath]);
} catch (error) {
console.error('[DeezerQueueManager] Error syncing track to library:', error);
// Non-fatal - track is downloaded, just not in database yet
}
}
/**
@@ -259,6 +276,18 @@ export class DeezerQueueManager {
await Promise.all(running);
console.log(`[DeezerQueueManager] Collection complete: ${completedCount} succeeded, ${failedCount} failed`);
// Trigger incremental library sync for all successfully downloaded tracks
if (completedCount > 0) {
try {
const successfulPaths = results.filter(r => typeof r === 'string') as string[];
await syncTrackPaths(successfulPaths);
console.log(`[DeezerQueueManager] Synced ${successfulPaths.length} tracks to library`);
} catch (error) {
console.error('[DeezerQueueManager] Error syncing collection to library:', error);
// Non-fatal - tracks are downloaded, just not in database yet
}
}
}
}