2022-06-06 15:20:46 +02:00
|
|
|
import {
|
|
|
|
|
Image,
|
|
|
|
|
Group,
|
|
|
|
|
Title,
|
|
|
|
|
Badge,
|
|
|
|
|
Text,
|
|
|
|
|
ActionIcon,
|
|
|
|
|
Anchor,
|
|
|
|
|
ScrollArea,
|
|
|
|
|
createStyles,
|
|
|
|
|
} from '@mantine/core';
|
2022-05-29 18:42:58 +02:00
|
|
|
import { IconLink as Link } from '@tabler/icons';
|
2022-05-25 13:13:36 +02:00
|
|
|
import { useConfig } from '../../../tools/state';
|
|
|
|
|
import { serviceItem } from '../../../tools/types';
|
2022-04-30 21:36:53 +02:00
|
|
|
|
|
|
|
|
export interface IMedia {
|
2022-05-09 22:03:09 +02:00
|
|
|
overview: string;
|
2022-05-25 10:50:57 +02:00
|
|
|
imdbId?: any;
|
|
|
|
|
artist?: string;
|
2022-04-30 21:36:53 +02:00
|
|
|
title: string;
|
2022-05-25 10:50:57 +02:00
|
|
|
poster?: string;
|
2022-04-30 21:36:53 +02:00
|
|
|
genres: string[];
|
2022-05-09 22:03:09 +02:00
|
|
|
seasonNumber?: number;
|
|
|
|
|
episodeNumber?: number;
|
2022-04-30 21:36:53 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-06 15:20:46 +02:00
|
|
|
const useStyles = createStyles((theme) => ({
|
|
|
|
|
poster: {
|
|
|
|
|
[theme.fn.smallerThan('sm')]: {
|
|
|
|
|
maxWidth: '20%',
|
|
|
|
|
},
|
|
|
|
|
[theme.fn.largerThan('sm')]: {
|
|
|
|
|
maxWidth: 300,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
overview: {
|
|
|
|
|
[theme.fn.largerThan('sm')]: {
|
|
|
|
|
width: 400,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}));
|
|
|
|
|
|
2022-05-31 19:59:31 +02:00
|
|
|
export function MediaDisplay(props: { media: IMedia }) {
|
2022-05-09 22:03:09 +02:00
|
|
|
const { media }: { media: IMedia } = props;
|
2022-06-06 15:20:46 +02:00
|
|
|
const { classes, cx } = useStyles();
|
2022-04-30 21:36:53 +02:00
|
|
|
return (
|
2022-05-25 13:13:36 +02:00
|
|
|
<Group position="apart">
|
|
|
|
|
<Text>
|
|
|
|
|
{media.poster && (
|
|
|
|
|
<Image
|
2022-06-06 15:20:46 +02:00
|
|
|
className={classes.poster}
|
2022-05-25 13:13:36 +02:00
|
|
|
style={{
|
|
|
|
|
float: 'right',
|
|
|
|
|
}}
|
|
|
|
|
radius="md"
|
|
|
|
|
fit="cover"
|
|
|
|
|
src={media.poster}
|
|
|
|
|
alt={media.title}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2022-05-25 18:26:13 +02:00
|
|
|
<Group direction="column">
|
2022-06-06 15:20:46 +02:00
|
|
|
<Group noWrap mr="sm" className={classes.overview}>
|
2022-05-25 18:26:13 +02:00
|
|
|
<Title order={3}>{media.title}</Title>
|
|
|
|
|
{media.imdbId && (
|
2022-05-26 20:07:54 +02:00
|
|
|
<Anchor href={`https://www.imdb.com/title/${media.imdbId}`} target="_blank">
|
2022-05-25 18:26:13 +02:00
|
|
|
<ActionIcon>
|
|
|
|
|
<Link />
|
|
|
|
|
</ActionIcon>
|
|
|
|
|
</Anchor>
|
|
|
|
|
)}
|
|
|
|
|
</Group>
|
2022-05-25 10:50:57 +02:00
|
|
|
{media.artist && (
|
|
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
textAlign: 'center',
|
2022-05-30 09:20:16 +02:00
|
|
|
color: 'gray',
|
2022-05-25 10:50:57 +02:00
|
|
|
}}
|
|
|
|
|
>
|
2022-05-25 13:13:36 +02:00
|
|
|
New release from {media.artist}
|
2022-05-25 10:50:57 +02:00
|
|
|
</Text>
|
|
|
|
|
)}
|
2022-05-09 22:03:09 +02:00
|
|
|
{media.episodeNumber && media.seasonNumber && (
|
|
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
textAlign: 'center',
|
2022-05-30 09:20:16 +02:00
|
|
|
color: 'gray',
|
2022-05-09 22:03:09 +02:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Season {media.seasonNumber} episode {media.episodeNumber}
|
|
|
|
|
</Text>
|
|
|
|
|
)}
|
2022-05-05 09:22:44 +02:00
|
|
|
</Group>
|
2022-05-25 13:13:36 +02:00
|
|
|
<Group direction="column" position="apart">
|
2022-06-06 15:20:46 +02:00
|
|
|
<ScrollArea style={{ maxHeight: 250, maxWidth: 700 }}>{media.overview}</ScrollArea>
|
2022-05-25 13:13:36 +02:00
|
|
|
<Group align="center" position="center" spacing="xs">
|
|
|
|
|
{media.genres.map((genre: string, i: number) => (
|
|
|
|
|
<Badge size="sm" key={i}>
|
|
|
|
|
{genre}
|
|
|
|
|
</Badge>
|
|
|
|
|
))}
|
|
|
|
|
</Group>
|
2022-05-05 09:22:44 +02:00
|
|
|
</Group>
|
2022-05-25 13:13:36 +02:00
|
|
|
</Text>
|
2022-05-05 09:22:44 +02:00
|
|
|
</Group>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-25 10:50:57 +02:00
|
|
|
export function ReadarrMediaDisplay(props: any) {
|
|
|
|
|
const { media }: { media: any } = props;
|
2022-05-25 13:13:36 +02:00
|
|
|
const { config } = useConfig();
|
|
|
|
|
// Find lidarr in services
|
|
|
|
|
const readarr = config.services.find((service: serviceItem) => service.type === 'Readarr');
|
2022-05-25 10:50:57 +02:00
|
|
|
// Find a poster CoverType
|
2022-05-25 13:13:36 +02:00
|
|
|
const poster = media.images.find((image: any) => image.coverType === 'cover');
|
|
|
|
|
if (!readarr) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
const baseUrl = new URL(readarr.url).origin;
|
|
|
|
|
// Remove '/' from the end of the lidarr url
|
|
|
|
|
const fullLink = `${baseUrl}${poster.url}`;
|
2022-05-25 10:50:57 +02:00
|
|
|
// Return a movie poster containting the title and the description
|
|
|
|
|
return (
|
|
|
|
|
<MediaDisplay
|
|
|
|
|
media={{
|
|
|
|
|
title: media.title,
|
2022-05-25 13:13:36 +02:00
|
|
|
poster: fullLink,
|
2022-05-25 10:50:57 +02:00
|
|
|
artist: media.author.authorName,
|
|
|
|
|
overview: media.overview,
|
|
|
|
|
genres: media.genres,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function LidarrMediaDisplay(props: any) {
|
|
|
|
|
const { media }: { media: any } = props;
|
2022-05-25 13:13:36 +02:00
|
|
|
const { config } = useConfig();
|
|
|
|
|
// Find lidarr in services
|
|
|
|
|
const lidarr = config.services.find((service: serviceItem) => service.type === 'Lidarr');
|
2022-05-25 10:50:57 +02:00
|
|
|
// Find a poster CoverType
|
2022-05-25 13:13:36 +02:00
|
|
|
const poster = media.images.find((image: any) => image.coverType === 'cover');
|
|
|
|
|
if (!lidarr) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
const baseUrl = new URL(lidarr.url).origin;
|
|
|
|
|
// Remove '/' from the end of the lidarr url
|
2022-05-30 21:43:33 +02:00
|
|
|
const fullLink = poster ? `${baseUrl}${poster.url}` : undefined;
|
2022-05-25 10:50:57 +02:00
|
|
|
// Return a movie poster containting the title and the description
|
|
|
|
|
return (
|
|
|
|
|
<MediaDisplay
|
|
|
|
|
media={{
|
|
|
|
|
title: media.title,
|
2022-05-25 13:13:36 +02:00
|
|
|
poster: fullLink,
|
2022-05-25 10:50:57 +02:00
|
|
|
artist: media.artist.artistName,
|
|
|
|
|
overview: media.overview,
|
|
|
|
|
genres: media.genres,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-09 22:03:09 +02:00
|
|
|
export function RadarrMediaDisplay(props: any) {
|
|
|
|
|
const { media }: { media: any } = props;
|
|
|
|
|
// Find a poster CoverType
|
|
|
|
|
const poster = media.images.find((image: any) => image.coverType === 'poster');
|
|
|
|
|
// Return a movie poster containting the title and the description
|
|
|
|
|
return (
|
|
|
|
|
<MediaDisplay
|
|
|
|
|
media={{
|
|
|
|
|
imdbId: media.imdbId,
|
|
|
|
|
title: media.title,
|
|
|
|
|
overview: media.overview,
|
|
|
|
|
poster: poster.url,
|
|
|
|
|
genres: media.genres,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-05 09:22:44 +02:00
|
|
|
export function SonarrMediaDisplay(props: any) {
|
|
|
|
|
const { media }: { media: any } = props;
|
|
|
|
|
// 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
|
|
|
|
|
return (
|
2022-05-09 22:03:09 +02:00
|
|
|
<MediaDisplay
|
|
|
|
|
media={{
|
|
|
|
|
imdbId: media.series.imdbId,
|
|
|
|
|
title: media.series.title,
|
|
|
|
|
overview: media.series.overview,
|
|
|
|
|
poster: poster.url,
|
|
|
|
|
genres: media.series.genres,
|
|
|
|
|
seasonNumber: media.seasonNumber,
|
|
|
|
|
episodeNumber: media.episodeNumber,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2022-04-30 21:36:53 +02:00
|
|
|
);
|
|
|
|
|
}
|