✨ Auto handle sonarr and radarr API differences (#1548)
This commit is contained in:
@@ -4,12 +4,6 @@
|
|||||||
"description": "Displays a calendar with upcoming releases, from supported integrations.",
|
"description": "Displays a calendar with upcoming releases, from supported integrations.",
|
||||||
"settings": {
|
"settings": {
|
||||||
"title": "Settings for Calendar widget",
|
"title": "Settings for Calendar widget",
|
||||||
"useSonarrv4": {
|
|
||||||
"label": "Use Sonarr v4 API"
|
|
||||||
},
|
|
||||||
"useRadarrv5": {
|
|
||||||
"label": "Use Radarr v5 API"
|
|
||||||
},
|
|
||||||
"radarrReleaseType": {
|
"radarrReleaseType": {
|
||||||
"label": "Radarr release type",
|
"label": "Radarr release type",
|
||||||
"data":{
|
"data":{
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export interface IMedia {
|
|||||||
episodetitle?: string;
|
episodetitle?: string;
|
||||||
voteAverage?: string;
|
voteAverage?: string;
|
||||||
poster?: string;
|
poster?: string;
|
||||||
|
altPoster?: string;
|
||||||
genres: string[];
|
genres: string[];
|
||||||
seasonNumber?: number;
|
seasonNumber?: number;
|
||||||
plexUrl?: string;
|
plexUrl?: string;
|
||||||
@@ -136,7 +137,6 @@ export function RadarrMediaDisplay(props: any) {
|
|||||||
const { media }: { media: any } = props;
|
const { media }: { media: any } = props;
|
||||||
const { config } = useConfigContext();
|
const { config } = useConfigContext();
|
||||||
const calendar = config?.widgets.find((w) => w.type === 'calendar');
|
const calendar = config?.widgets.find((w) => w.type === 'calendar');
|
||||||
const useRadarrv5 = calendar?.properties.useRadarrv5 ?? false;
|
|
||||||
|
|
||||||
// Find a poster CoverType
|
// Find a poster CoverType
|
||||||
const poster = media.images.find((image: any) => image.coverType === 'poster');
|
const poster = media.images.find((image: any) => image.coverType === 'poster');
|
||||||
@@ -147,7 +147,8 @@ export function RadarrMediaDisplay(props: any) {
|
|||||||
title: media.title ?? media.originalTitle,
|
title: media.title ?? media.originalTitle,
|
||||||
overview: media.overview ?? '',
|
overview: media.overview ?? '',
|
||||||
genres: media.genres ?? [],
|
genres: media.genres ?? [],
|
||||||
poster: useRadarrv5 ? poster.remoteUrl : poster.url,
|
poster: poster.url,
|
||||||
|
altPoster: poster.remoteUrl,
|
||||||
voteAverage: media.ratings.tmdb.value.toString(),
|
voteAverage: media.ratings.tmdb.value.toString(),
|
||||||
imdbId: media.imdbId,
|
imdbId: media.imdbId,
|
||||||
type: 'movie',
|
type: 'movie',
|
||||||
@@ -160,7 +161,6 @@ export function SonarrMediaDisplay(props: any) {
|
|||||||
const { media }: { media: any } = props;
|
const { media }: { media: any } = props;
|
||||||
const { config } = useConfigContext();
|
const { config } = useConfigContext();
|
||||||
const calendar = config?.widgets.find((w) => w.type === 'calendar');
|
const calendar = config?.widgets.find((w) => w.type === 'calendar');
|
||||||
const useSonarrv4 = calendar?.properties.useSonarrv4 ?? false;
|
|
||||||
|
|
||||||
// Find a poster CoverType
|
// Find a poster CoverType
|
||||||
const poster = media.series.images.find((image: any) => image.coverType === 'poster');
|
const poster = media.series.images.find((image: any) => image.coverType === 'poster');
|
||||||
@@ -172,7 +172,8 @@ export function SonarrMediaDisplay(props: any) {
|
|||||||
genres: media.series.genres ?? [],
|
genres: media.series.genres ?? [],
|
||||||
overview: media.overview ?? media.series.overview ?? '',
|
overview: media.overview ?? media.series.overview ?? '',
|
||||||
title: media.series.title,
|
title: media.series.title,
|
||||||
poster: useSonarrv4 ? poster.remoteUrl : poster.url,
|
poster: poster.url,
|
||||||
|
altPoster: poster.remoteUrl,
|
||||||
episodeNumber: media.episodeNumber,
|
episodeNumber: media.episodeNumber,
|
||||||
seasonNumber: media.seasonNumber,
|
seasonNumber: media.seasonNumber,
|
||||||
episodetitle: media.title,
|
episodetitle: media.title,
|
||||||
@@ -191,7 +192,7 @@ export function MediaDisplay({ media }: { media: IMedia }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Group noWrap style={{ maxHeight: 250, maxWidth: 400 }} p={0} m={0} spacing="xs">
|
<Group noWrap style={{ maxHeight: 250, maxWidth: 400 }} p={0} m={0} spacing="xs">
|
||||||
<Image src={media.poster} height={200} width={150} radius="md" fit="cover" />
|
<Image src={media.poster?? media.altPoster} height={200} width={150} radius="md" fit="cover" withPlaceholder/>
|
||||||
<Stack justify="space-around">
|
<Stack justify="space-around">
|
||||||
<Stack spacing="sm">
|
<Stack spacing="sm">
|
||||||
<Text lineClamp={2}>
|
<Text lineClamp={2}>
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ export const calendarRouter = createTRPCRouter({
|
|||||||
month: z.number().min(1).max(12),
|
month: z.number().min(1).max(12),
|
||||||
year: z.number().min(1900).max(2300),
|
year: z.number().min(1900).max(2300),
|
||||||
options: z.object({
|
options: z.object({
|
||||||
useSonarrv4: z.boolean().optional().default(false),
|
|
||||||
showUnmonitored: z.boolean().optional().default(false),
|
showUnmonitored: z.boolean().optional().default(false),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
@@ -35,7 +34,7 @@ export const calendarRouter = createTRPCRouter({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const integrationTypeEndpointMap = new Map<AppIntegrationType['type'], string>([
|
const integrationTypeEndpointMap = new Map<AppIntegrationType['type'], string>([
|
||||||
['sonarr', input.options.useSonarrv4 ? '/api/v3/calendar' : '/api/calendar'],
|
['sonarr', '/api/v3/calendar'],
|
||||||
['radarr', '/api/v3/calendar'],
|
['radarr', '/api/v3/calendar'],
|
||||||
['lidarr', '/api/v1/calendar'],
|
['lidarr', '/api/v1/calendar'],
|
||||||
['readarr', '/api/v1/calendar'],
|
['readarr', '/api/v1/calendar'],
|
||||||
|
|||||||
@@ -26,14 +26,6 @@ const definition = defineWidget({
|
|||||||
type: 'switch',
|
type: 'switch',
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
useSonarrv4: {
|
|
||||||
type: 'switch',
|
|
||||||
defaultValue: false,
|
|
||||||
},
|
|
||||||
useRadarrv5: {
|
|
||||||
type: 'switch',
|
|
||||||
defaultValue: false,
|
|
||||||
},
|
|
||||||
radarrReleaseType: {
|
radarrReleaseType: {
|
||||||
type: 'select',
|
type: 'select',
|
||||||
defaultValue: 'inCinemas',
|
defaultValue: 'inCinemas',
|
||||||
@@ -78,7 +70,6 @@ function CalendarTile({ widget }: CalendarTileProps) {
|
|||||||
month: month.getMonth() + 1,
|
month: month.getMonth() + 1,
|
||||||
year: month.getFullYear(),
|
year: month.getFullYear(),
|
||||||
options: {
|
options: {
|
||||||
useSonarrv4: widget.properties.useSonarrv4,
|
|
||||||
showUnmonitored: widget.properties.showUnmonitored,
|
showUnmonitored: widget.properties.showUnmonitored,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user