feat(purchases): create quality subfolder for downloads
Append a subfolder named after the selected format quality (e.g. "FLAC 24-bit - 96 kHz") to the user-chosen destination. Different quality downloads of the same album no longer overwrite each other.
This commit is contained in:
1 parent
d8f28385d9
commit
318318a3ab
2 files changed
+13
-3
No files matched your search
@@ -111,6 +111,12 @@
|
||||
return `${mins}m`;
|
||||
}
|
||||
|
||||
function qualityFolderName(formatId: number): string {
|
||||
const fmt = formats.find((f) => f.id === formatId);
|
||||
if (!fmt) return '';
|
||||
return fmt.label.replace(/\//g, '-').trim();
|
||||
}
|
||||
|
||||
async function promptForFolder(action: 'all' | number) {
|
||||
if (!album || selectedFormatId === null) return;
|
||||
try {
|
||||
@@ -124,11 +130,13 @@
|
||||
title: get(t)('purchases.chooseFolder'),
|
||||
});
|
||||
if (dest && typeof dest === 'string') {
|
||||
const qualityDir = qualityFolderName(selectedFormatId);
|
||||
const finalDest = qualityDir ? `${dest}/${qualityDir}` : dest;
|
||||
if (action === 'all') {
|
||||
const trackIds = (album.tracks?.items || []).map((track) => track.id);
|
||||
startAlbumDownload(albumId, trackIds, selectedFormatId, dest);
|
||||
startAlbumDownload(albumId, trackIds, selectedFormatId, finalDest);
|
||||
} else {
|
||||
startTrackDownload(albumId, action, selectedFormatId, dest);
|
||||
startTrackDownload(albumId, action, selectedFormatId, finalDest);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
@@ -410,7 +410,9 @@
|
||||
|
||||
if (!dest || typeof dest !== 'string') return;
|
||||
|
||||
startTrackDownload(track.album.id, track.id, formats[0].id, dest);
|
||||
const qualityDir = formats[0].label.replace(/\//g, '-').trim();
|
||||
const finalDest = qualityDir ? `${dest}/${qualityDir}` : dest;
|
||||
startTrackDownload(track.album.id, track.id, formats[0].id, finalDest);
|
||||
} catch (err) {
|
||||
console.error('Track download error:', err);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user