diff --git a/public/locales/en/modules/calendar.json b/public/locales/en/modules/calendar.json index fe7fc32ce..5b3aefe0f 100644 --- a/public/locales/en/modules/calendar.json +++ b/public/locales/en/modules/calendar.json @@ -4,6 +4,9 @@ "description": "Displays a calendar with upcoming releases, from supported integrations.", "settings": { "title": "Settings for Calendar widget", + "useSonarrv4": { + "label": "Use Sonarr v4 API" + }, "sundayStart": { "label": "Start the week on Sunday" }, diff --git a/src/modules/common/MediaDisplay.tsx b/src/modules/common/MediaDisplay.tsx index 61344cf34..453a262e3 100644 --- a/src/modules/common/MediaDisplay.tsx +++ b/src/modules/common/MediaDisplay.tsx @@ -152,6 +152,10 @@ export function RadarrMediaDisplay(props: any) { export function SonarrMediaDisplay(props: any) { const { media }: { media: any } = props; + const { config } = useConfigContext(); + const calendar = config?.widgets.find((w) => w.id === 'calendar'); + const useSonarrv4 = calendar?.properties.useSonarrv4 ?? false; + // Find a poster CoverType const poster = media.series.images.find((image: any) => image.coverType === 'poster'); // Return a movie poster containting the title and the description @@ -162,7 +166,7 @@ export function SonarrMediaDisplay(props: any) { genres: media.series.genres ?? [], overview: media.overview ?? media.series.overview ?? '', title: media.series.title, - poster: poster ? poster.url : undefined, + poster: useSonarrv4 ? poster.remoteUrl : poster.url, episodeNumber: media.episodeNumber, seasonNumber: media.seasonNumber, episodetitle: media.title, diff --git a/src/pages/api/modules/calendar.ts b/src/pages/api/modules/calendar.ts index d454497a9..dd90fc8c8 100644 --- a/src/pages/api/modules/calendar.ts +++ b/src/pages/api/modules/calendar.ts @@ -35,6 +35,10 @@ async function Get(req: NextApiRequest, res: NextApiResponse) { const config = getConfig(configName); + // Find the calendar widget in the config + const calendar = config.widgets.find((w) => w.id === 'calendar'); + const useSonarrv4 = calendar?.properties.useSonarrv4 ?? false; + const mediaAppIntegrationTypes: AppIntegrationType['type'][] = [ 'sonarr', 'radarr', @@ -45,6 +49,13 @@ async function Get(req: NextApiRequest, res: NextApiResponse) { (app) => app.integration && mediaAppIntegrationTypes.includes(app.integration.type) ); + const IntegrationTypeEndpointMap = new Map([ + ['sonarr', useSonarrv4 ? '/api/v3/calendar' : '/api/calendar'], + ['radarr', '/api/v3/calendar'], + ['lidarr', '/api/v1/calendar'], + ['readarr', '/api/v1/calendar'], + ]); + try { const medias = await Promise.all( await mediaApps.map(async (app) => { @@ -71,7 +82,7 @@ async function Get(req: NextApiRequest, res: NextApiResponse) { if (!apiKey) return { type: integration.type, items: [], success: false }; return axios .get( - `${origin}${endpoint}?apiKey=${apiKey}&end=${end.toISOString()}&start=${start.toISOString()}` + `${origin}${endpoint}?apiKey=${apiKey}&end=${end.toISOString()}&start=${start.toISOString()}&includeSeries=true&includeEpisodeFile=true&includeEpisodeImages=true` ) .then((x) => ({ type: integration.type, items: x.data as any[], success: true })) .catch((err) => { @@ -87,7 +98,7 @@ async function Get(req: NextApiRequest, res: NextApiResponse) { }) ); - const countFailed = medias.filter(x => !x.success).length; + const countFailed = medias.filter((x) => !x.success).length; if (countFailed > 0) { Consola.warn(`A total of ${countFailed} apps for the calendar widget failed`); } @@ -111,10 +122,3 @@ async function Get(req: NextApiRequest, res: NextApiResponse) { }); } } - -const IntegrationTypeEndpointMap = new Map([ - ['sonarr', '/api/calendar'], - ['radarr', '/api/v3/calendar'], - ['lidarr', '/api/v1/calendar'], - ['readarr', '/api/v1/calendar'], -]); diff --git a/src/widgets/calendar/CalendarTile.tsx b/src/widgets/calendar/CalendarTile.tsx index f076160e3..f06ca88d2 100644 --- a/src/widgets/calendar/CalendarTile.tsx +++ b/src/widgets/calendar/CalendarTile.tsx @@ -16,6 +16,10 @@ const definition = defineWidget({ id: 'calendar', icon: IconCalendarTime, options: { + useSonarrv4: { + type: 'switch', + defaultValue: false, + }, sundayStart: { type: 'switch', defaultValue: false,