Make kept path configurable via web UI

- Added Library:KeptPath to appsettings.json (default: /app/kept)
- Added Library Settings card to web UI with DownloadPath and KeptPath
- Updated GetDownloads and DeleteDownload endpoints to use configured path
- Updated JellyfinController to use configured kept path
- Injected IConfiguration into JellyfinController
- Users can now customize where favorited tracks are stored
This commit is contained in:
2026-02-07 00:35:12 -05:00
parent c9b44dea43
commit 440ef9850f
4 changed files with 35 additions and 6 deletions

View File

@@ -1450,6 +1450,11 @@ public class AdminController : ControllerBase
userId = _jellyfinSettings.UserId ?? "(not set)",
libraryId = _jellyfinSettings.LibraryId
},
library = new
{
downloadPath = _configuration["Library:DownloadPath"] ?? "./downloads",
keptPath = _configuration["Library:KeptPath"] ?? "/app/kept"
},
deezer = new
{
arl = MaskValue(_deezerSettings.Arl, showLast: 8),
@@ -3331,7 +3336,7 @@ public class LinkPlaylistRequest
{
try
{
var keptPath = "/app/kept";
var keptPath = _configuration["Library:KeptPath"] ?? "/app/kept";
_logger.LogInformation("📂 Checking kept folder: {Path}", keptPath);
_logger.LogInformation("📂 Directory exists: {Exists}", Directory.Exists(keptPath));
@@ -3414,7 +3419,7 @@ public class LinkPlaylistRequest
return BadRequest(new { error = "Path is required" });
}
var keptPath = "/app/kept";
var keptPath = _configuration["Library:KeptPath"] ?? "/app/kept";
var fullPath = Path.Combine(keptPath, path);
_logger.LogInformation("🗑️ Delete request for: {Path}", fullPath);

View File

@@ -41,6 +41,7 @@ public class JellyfinController : ControllerBase
private readonly SpotifyLyricsService? _spotifyLyricsService;
private readonly LrclibService? _lrclibService;
private readonly RedisCacheService _cache;
private readonly IConfiguration _configuration;
private readonly ILogger<JellyfinController> _logger;
public JellyfinController(
@@ -55,6 +56,7 @@ public class JellyfinController : ControllerBase
JellyfinProxyService proxyService,
JellyfinSessionManager sessionManager,
RedisCacheService cache,
IConfiguration configuration,
ILogger<JellyfinController> logger,
ParallelMetadataService? parallelMetadataService = null,
PlaylistSyncService? playlistSyncService = null,
@@ -78,6 +80,7 @@ public class JellyfinController : ControllerBase
_spotifyLyricsService = spotifyLyricsService;
_lrclibService = lrclibService;
_cache = cache;
_configuration = configuration;
_logger = logger;
if (string.IsNullOrWhiteSpace(_settings.Url))
@@ -3787,8 +3790,8 @@ public class JellyfinController : ControllerBase
return;
}
// Build kept folder path: /app/kept/Artist/Album/
var keptBasePath = "/app/kept";
// Build kept folder path: Artist/Album/
var keptBasePath = _configuration["Library:KeptPath"] ?? "/app/kept";
var keptArtistPath = Path.Combine(keptBasePath, PathHelper.SanitizeFileName(song.Artist));
var keptAlbumPath = Path.Combine(keptArtistPath, PathHelper.SanitizeFileName(song.Album));
@@ -4084,7 +4087,7 @@ public class JellyfinController : ControllerBase
var song = await _metadataService.GetSongAsync(provider!, externalId!);
if (song == null) return;
var keptBasePath = "/app/kept";
var keptBasePath = _configuration["Library:KeptPath"] ?? "/app/kept";
var keptArtistPath = Path.Combine(keptBasePath, PathHelper.SanitizeFileName(song.Artist));
var keptAlbumPath = Path.Combine(keptArtistPath, PathHelper.SanitizeFileName(song.Album));

View File

@@ -32,7 +32,8 @@
"EnableExternalPlaylists": true
},
"Library": {
"DownloadPath": "./downloads"
"DownloadPath": "./downloads",
"KeptPath": "/app/kept"
},
"Qobuz": {
"UserAuthToken": "your-qobuz-token",

View File

@@ -920,6 +920,22 @@
</div>
</div>
<div class="card">
<h2>Library Settings</h2>
<div class="config-section">
<div class="config-item">
<span class="label">Download Path (Cache)</span>
<span class="value" id="config-download-path">-</span>
<button onclick="openEditSetting('LIBRARY_DOWNLOAD_PATH', 'Download Path', 'text')">Edit</button>
</div>
<div class="config-item">
<span class="label">Kept Path (Favorited)</span>
<span class="value" id="config-kept-path">-</span>
<button onclick="openEditSetting('LIBRARY_KEPT_PATH', 'Kept Path', 'text')">Edit</button>
</div>
</div>
</div>
<div class="card">
<h2>Sync Schedule</h2>
<div class="config-section">
@@ -1687,6 +1703,10 @@
document.getElementById('config-jellyfin-user-id').textContent = data.jellyfin.userId || '(not set)';
document.getElementById('config-jellyfin-library-id').textContent = data.jellyfin.libraryId || '-';
// Library settings
document.getElementById('config-download-path').textContent = data.library?.downloadPath || './downloads';
document.getElementById('config-kept-path').textContent = data.library?.keptPath || '/app/kept';
// Sync settings
const syncHour = data.spotifyImport.syncStartHour;
const syncMin = data.spotifyImport.syncStartMinute;