2022-05-29 21:39:57 +02:00
|
|
|
import {
|
|
|
|
|
Image,
|
|
|
|
|
Group,
|
|
|
|
|
Title,
|
|
|
|
|
Badge,
|
|
|
|
|
Text,
|
|
|
|
|
ActionIcon,
|
|
|
|
|
Anchor,
|
|
|
|
|
ScrollArea,
|
2022-06-06 15:20:46 +02:00
|
|
|
createStyles,
|
2022-08-02 05:21:30 +02:00
|
|
|
Stack,
|
2022-08-07 17:20:59 +02:00
|
|
|
Button,
|
2022-05-29 21:39:57 +02:00
|
|
|
} from '@mantine/core';
|
2022-06-06 22:32:57 +02:00
|
|
|
import { useMediaQuery } from '@mantine/hooks';
|
2022-07-24 23:48:48 +02:00
|
|
|
import { IconLink } from '@tabler/icons';
|
2022-07-23 22:22:55 +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-07-24 23:48:48 +02:00
|
|
|
voteAverage?: 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;
|
2022-05-27 00:32:27 +02:00
|
|
|
plexUrl?: string;
|
2022-05-09 22:03:09 +02:00
|
|
|
episodeNumber?: number;
|
2022-08-07 12:16:15 +02:00
|
|
|
[key: string]: any;
|
2022-04-30 21:36:53 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-06 15:20:46 +02:00
|
|
|
const useStyles = createStyles((theme) => ({
|
|
|
|
|
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-06-06 22:32:57 +02:00
|
|
|
const phone = useMediaQuery('(min-width: 800px)');
|
2022-04-30 21:36:53 +02:00
|
|
|
return (
|
2022-05-27 00:32:27 +02:00
|
|
|
<Group {...props} position="apart">
|
2022-05-25 13:13:36 +02:00
|
|
|
<Text>
|
|
|
|
|
{media.poster && (
|
|
|
|
|
<Image
|
2022-06-06 22:32:57 +02:00
|
|
|
width={phone ? 250 : 100}
|
|
|
|
|
height={phone ? 400 : 160}
|
2022-05-25 13:13:36 +02:00
|
|
|
style={{
|
|
|
|
|
float: 'right',
|
|
|
|
|
}}
|
|
|
|
|
radius="md"
|
|
|
|
|
fit="cover"
|
|
|
|
|
src={media.poster}
|
|
|
|
|
alt={media.title}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2022-08-02 05:21:30 +02:00
|
|
|
<Stack style={{ minWidth: phone ? 450 : '65vw' }}>
|
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>
|
2022-07-24 23:48:48 +02:00
|
|
|
{media.artist && <Text color="gray">New release from {media.artist}</Text>}
|
|
|
|
|
{(media.episodeNumber || media.seasonNumber) && (
|
|
|
|
|
<Text color="gray">
|
|
|
|
|
Season {media.seasonNumber}{' '}
|
|
|
|
|
{media.episodeNumber && `episode ${media.episodeNumber}`}
|
|
|
|
|
</Text>
|
2022-05-25 18:26:13 +02:00
|
|
|
)}
|
|
|
|
|
</Group>
|
2022-07-24 23:48:48 +02:00
|
|
|
{media.voteAverage && (
|
|
|
|
|
<Button
|
|
|
|
|
radius="md"
|
|
|
|
|
variant="light"
|
|
|
|
|
color={media.plexUrl ? 'green' : 'cyan'}
|
|
|
|
|
size="md"
|
|
|
|
|
onClick={
|
|
|
|
|
media.plexUrl
|
|
|
|
|
? () => window.open(media.plexUrl)
|
|
|
|
|
: () => {
|
|
|
|
|
// TODO: implement overseerr media requests
|
2022-08-07 12:16:15 +02:00
|
|
|
console.log(media);
|
2022-07-24 23:48:48 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-05-25 10:50:57 +02:00
|
|
|
>
|
2022-07-24 23:48:48 +02:00
|
|
|
{media.plexUrl ? 'Available on Plex' : 'Request'}
|
|
|
|
|
</Button>
|
2022-05-25 10:50:57 +02:00
|
|
|
)}
|
2022-07-24 23:48:48 +02:00
|
|
|
{media.imdbId && (
|
|
|
|
|
<Anchor href={`https://www.imdb.com/title/${media.imdbId}`} target="_blank">
|
|
|
|
|
<ActionIcon>
|
|
|
|
|
<IconLink />
|
|
|
|
|
</ActionIcon>
|
|
|
|
|
</Anchor>
|
2022-05-09 22:03:09 +02:00
|
|
|
)}
|
2022-08-02 05:21:30 +02:00
|
|
|
</Stack>
|
|
|
|
|
<Stack>
|
2022-06-06 23:56:33 +02:00
|
|
|
<ScrollArea style={{ height: 280, maxWidth: 700 }}>{media.overview}</ScrollArea>
|
2022-05-25 13:13:36 +02:00
|
|
|
<Group align="center" position="center" spacing="xs">
|
2022-06-06 23:56:33 +02:00
|
|
|
{media.genres.slice(-5).map((genre: string, i: number) => (
|
2022-05-25 13:13:36 +02:00
|
|
|
<Badge size="sm" key={i}>
|
|
|
|
|
{genre}
|
|
|
|
|
</Badge>
|
|
|
|
|
))}
|
|
|
|
|
</Group>
|
2022-08-02 05:21:30 +02:00
|
|
|
</Stack>
|
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
|
|
|
);
|
|
|
|
|
}
|