added custom formatting to everything else (?)
This commit is contained in:
@@ -242,7 +242,9 @@ async function startDownload(url, type, item, albumType) {
|
||||
deezer = '',
|
||||
spotifyQuality = 'NORMAL',
|
||||
deezerQuality = 'MP3_128',
|
||||
realTime = false
|
||||
realTime = false,
|
||||
customDirFormat = '%ar_album%/%album%', // Default directory format
|
||||
customTrackFormat = '%tracknum%. %music%' // Default track format
|
||||
} = config;
|
||||
|
||||
const service = url.includes('open.spotify.com') ? 'spotify' : 'deezer';
|
||||
@@ -266,6 +268,10 @@ async function startDownload(url, type, item, albumType) {
|
||||
apiUrl += '&real_time=true';
|
||||
}
|
||||
|
||||
// Add custom formatting parameters to the API request
|
||||
apiUrl += `&custom_dir_format=${encodeURIComponent(customDirFormat)}`;
|
||||
apiUrl += `&custom_track_format=${encodeURIComponent(customTrackFormat)}`;
|
||||
|
||||
try {
|
||||
const response = await fetch(apiUrl);
|
||||
const data = await response.json();
|
||||
|
||||
@@ -98,6 +98,7 @@ function attachDownloadListeners(items) {
|
||||
}
|
||||
|
||||
async function startDownload(url, type, item, albumType) {
|
||||
// Retrieve configuration (if any) from localStorage
|
||||
const config = JSON.parse(localStorage.getItem('activeConfig')) || {};
|
||||
const {
|
||||
fallback = false,
|
||||
@@ -105,7 +106,9 @@ async function startDownload(url, type, item, albumType) {
|
||||
deezer = '',
|
||||
spotifyQuality = 'NORMAL',
|
||||
deezerQuality = 'MP3_128',
|
||||
realTime = false
|
||||
realTime = false,
|
||||
customTrackFormat = '',
|
||||
customDirFormat = ''
|
||||
} = config;
|
||||
|
||||
let service = url.includes('open.spotify.com') ? 'spotify' : 'deezer';
|
||||
@@ -125,6 +128,14 @@ async function startDownload(url, type, item, albumType) {
|
||||
|
||||
if (realTime) apiUrl += '&real_time=true';
|
||||
|
||||
// Append custom formatting parameters if present.
|
||||
if (customTrackFormat) {
|
||||
apiUrl += `&custom_track_format=${encodeURIComponent(customTrackFormat)}`;
|
||||
}
|
||||
if (customDirFormat) {
|
||||
apiUrl += `&custom_dir_format=${encodeURIComponent(customDirFormat)}`;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(apiUrl);
|
||||
const data = await response.json();
|
||||
|
||||
@@ -104,7 +104,6 @@ function renderPlaylist(playlist) {
|
||||
playlist.tracks.items.forEach((item, index) => {
|
||||
const track = item.track;
|
||||
// Create links for track, artist, and album using their IDs.
|
||||
// Ensure that track.id, track.artists[0].id, and track.album.id are available.
|
||||
const trackLink = `/track/${track.id}`;
|
||||
const artistLink = `/artist/${track.artists[0].id}`;
|
||||
const albumLink = `/album/${track.album.id}`;
|
||||
@@ -208,7 +207,9 @@ async function startDownload(url, type, item, albumType) {
|
||||
deezer = '',
|
||||
spotifyQuality = 'NORMAL',
|
||||
deezerQuality = 'MP3_128',
|
||||
realTime = false
|
||||
realTime = false,
|
||||
customTrackFormat = '',
|
||||
customDirFormat = ''
|
||||
} = config;
|
||||
|
||||
const service = url.includes('open.spotify.com') ? 'spotify' : 'deezer';
|
||||
@@ -238,6 +239,14 @@ async function startDownload(url, type, item, albumType) {
|
||||
apiUrl += '&real_time=true';
|
||||
}
|
||||
|
||||
// Append custom formatting parameters.
|
||||
if (customTrackFormat) {
|
||||
apiUrl += `&custom_track_format=${encodeURIComponent(customTrackFormat)}`;
|
||||
}
|
||||
if (customDirFormat) {
|
||||
apiUrl += `&custom_dir_format=${encodeURIComponent(customDirFormat)}`;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(apiUrl);
|
||||
const data = await response.json();
|
||||
|
||||
@@ -146,7 +146,9 @@ async function startDownload(url, type, item) {
|
||||
deezer = '',
|
||||
spotifyQuality = 'NORMAL',
|
||||
deezerQuality = 'MP3_128',
|
||||
realTime = false
|
||||
realTime = false,
|
||||
customTrackFormat = '',
|
||||
customDirFormat = ''
|
||||
} = config;
|
||||
|
||||
const service = url.includes('open.spotify.com') ? 'spotify' : 'deezer';
|
||||
@@ -164,6 +166,14 @@ async function startDownload(url, type, item) {
|
||||
apiUrl += '&real_time=true';
|
||||
}
|
||||
|
||||
// Append custom formatting parameters if they are set.
|
||||
if (customTrackFormat) {
|
||||
apiUrl += `&custom_track_format=${encodeURIComponent(customTrackFormat)}`;
|
||||
}
|
||||
if (customDirFormat) {
|
||||
apiUrl += `&custom_dir_format=${encodeURIComponent(customDirFormat)}`;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(apiUrl);
|
||||
const data = await response.json();
|
||||
|
||||
Reference in New Issue
Block a user