Add Lidarr library update command and UI trigger
This commit is contained in:
parent
abf9d61d72
commit
712d29921d
3 changed files with 57 additions and 0 deletions
35
server.js
35
server.js
|
|
@ -176,6 +176,30 @@ async function triggerAlbumSearch(albumId) {
|
|||
});
|
||||
}
|
||||
|
||||
async function triggerLibraryUpdate() {
|
||||
const started = [];
|
||||
|
||||
try {
|
||||
await lidarrRequest('post', '/api/v1/command', { name: 'RescanFolders' });
|
||||
started.push('RescanFolders');
|
||||
} catch (err) {
|
||||
console.warn('RescanFolders konnte nicht gestartet werden:', err.message);
|
||||
}
|
||||
|
||||
try {
|
||||
await lidarrRequest('post', '/api/v1/command', { name: 'RefreshArtist' });
|
||||
started.push('RefreshArtist');
|
||||
} catch (err) {
|
||||
console.warn('RefreshArtist konnte nicht gestartet werden:', err.message);
|
||||
}
|
||||
|
||||
if (started.length === 0) {
|
||||
throw new Error('Kein Bibliothek-Update-Kommando konnte in Lidarr gestartet werden.');
|
||||
}
|
||||
|
||||
return started;
|
||||
}
|
||||
|
||||
async function cleanupUnselectedTrackFiles(albumId, selectedTrackIds) {
|
||||
const allFiles = await fetchTrackFiles(albumId);
|
||||
if (!Array.isArray(allFiles) || allFiles.length === 0) {
|
||||
|
|
@ -416,6 +440,17 @@ app.post('/api/lidarr/send-album', async (req, res) => {
|
|||
}
|
||||
});
|
||||
|
||||
app.post('/api/lidarr/update-library', async (_req, res) => {
|
||||
try {
|
||||
const commandNames = await triggerLibraryUpdate();
|
||||
res.json({ success: true, commandNames });
|
||||
} catch (err) {
|
||||
const status = err.response?.status || 500;
|
||||
const details = err.response?.data || err.message;
|
||||
res.status(status).json({ error: typeof details === 'string' ? details : JSON.stringify(details) });
|
||||
}
|
||||
});
|
||||
|
||||
app.get('*', (_req, res) => {
|
||||
res.sendFile(path.join(__dirname, 'public', 'index.html'));
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue