feat: add movie deletion action

This commit is contained in:
WonderAliceUwU committed 2026-09-07 18:35:21 +02:00
1 parent b06792cc24
commit c70a8999cd
6 files changed
+142 -10

No files matched your search

+10
View File
@@ -10,6 +10,7 @@ import {
type DiskSpaceStatus,
type HubPageResponse,
type JellyfinLoginPayload,
type MovieDeletePayload,
type SeasonDeletePayload,
type SeasonRequestPayload,
type TitleDetailsRequest
@@ -25,6 +26,7 @@ import {
searchTitles,
getTitleDetails,
getTmdbLogos,
deleteMovieFiles,
deleteSeasonFiles,
getServiceOptions,
loadJellyfinUsers,
@@ -426,6 +428,14 @@ async function routeRequest(request: IncomingMessage, response: ServerResponse):
return;
}
if (url.pathname === '/api/movies/delete' && method === 'POST') {
const config = await readConfig(session!.encryptionKey);
const body = await readJson<MovieDeletePayload>(request);
await deleteMovieFiles(config, body);
sendJson(response, 200, { ok: true });
return;
}
if (url.pathname.startsWith('/api/assets/jellyfin/') && method === 'GET') {
const config = await readConfig(session!.encryptionKey);
const itemId = decodeURIComponent(url.pathname.replace('/api/assets/jellyfin/', ''));
+30
View File
@@ -13,6 +13,7 @@ import type {
HubPageResponse,
HubSection,
MediaCard,
MovieDeletePayload,
ProcessingItem,
SeasonDeletePayload,
SeasonRequestPayload,
@@ -2740,6 +2741,35 @@ export async function deleteSeasonFiles(config: AppConfig, payload: SeasonDelete
);
}
export async function deleteMovieFiles(config: AppConfig, payload: MovieDeletePayload): Promise<void> {
if (!config.radarr.baseUrl || !config.radarr.apiKey) {
throw new Error('Radarr is not configured.');
}
if (!payload.movieId) {
throw new Error('Movie id is required.');
}
const baseUrl = config.radarr.baseUrl.endsWith('/') ? config.radarr.baseUrl : `${config.radarr.baseUrl}/`;
const movieUrl = new URL(`api/v3/movie/${encodeURIComponent(String(payload.movieId))}`, baseUrl);
movieUrl.searchParams.set('deleteFiles', 'true');
movieUrl.searchParams.set('addImportExclusion', 'false');
const response = await fetch(movieUrl, {
method: 'DELETE',
headers: {
'X-Api-Key': config.radarr.apiKey
}
});
if (!response.ok) {
const detail = (await response.text()).trim();
throw new Error(detail
? `Radarr ${response.status} ${response.statusText}: ${detail}`
: `Radarr ${response.status} ${response.statusText}`);
}
}
export async function setEpisodeWatchState(config: AppConfig, payload: EpisodeWatchStateRequest): Promise<void> {
if (!config.jellyfin.baseUrl || !config.jellyfin.apiKey || !config.jellyfin.userId) {
throw new Error('Jellyfin is not configured.');