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