feat: radarr integration (#1053)

* feat: sonarr integration

* fix: reviewed changes
This commit is contained in:
Yossi Hillali
2024-09-07 21:58:40 +03:00
committed by GitHub
parent 5404cebf5b
commit e88854c0e5
4 changed files with 141 additions and 9 deletions

View File

@@ -5,7 +5,7 @@ import { decryptSecret } from "@homarr/common";
import { EVERY_MINUTE } from "@homarr/cron-jobs-core/expressions";
import { db, eq } from "@homarr/db";
import { items } from "@homarr/db/schema/sqlite";
import { SonarrIntegration } from "@homarr/integrations";
import { integrationCreatorByKind } from "@homarr/integrations";
import type { CalendarEvent } from "@homarr/integrations/types";
import { createItemAndIntegrationChannel } from "@homarr/redis";
@@ -41,14 +41,17 @@ export const mediaOrganizerJob = createCronJob("mediaOrganizer", EVERY_MINUTE).w
const start = dayjs().subtract(Number(options.filterPastMonths), "months").toDate();
const end = dayjs().add(Number(options.filterFutureMonths), "months").toDate();
const sonarr = new SonarrIntegration({
const decryptedSecrets = integration.integration.secrets.map((secret) => ({
...secret,
value: decryptSecret(secret.value),
}));
const integrationInstance = integrationCreatorByKind(integration.integration.kind as "radarr" | "sonarr", {
...integration.integration,
decryptedSecrets: integration.integration.secrets.map((secret) => ({
...secret,
value: decryptSecret(secret.value),
})),
decryptedSecrets,
});
const events = await sonarr.getCalendarEventsAsync(start, end);
const events = await integrationInstance.getCalendarEventsAsync(start, end);
const cache = createItemAndIntegrationChannel<CalendarEvent[]>("calendar", integration.integrationId);
await cache.setAsync(events);