Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Secondary Media Info & Media Info Stats #5938

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/components/listview/List/ListContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ const ListContent: FC<ListContentProps> = ({
{listOptions.showMediaInfo !== false && enableSideMediaInfo && (
<PrimaryMediaInfo
className='secondary listItemMediaInfo'
infoclass='mediaInfoText'
item={item}
isRuntimeEnabled={true}
isStarRatingEnabled={true}
isCaptionIndicatorEnabled={true}
isEpisodeTitleEnabled={true}
isOfficialRatingEnabled={true}
showRuntimeInfo
showOfficialRatingInfo
showOriginalAirDateInfo
showStarRatingInfo
showCaptionIndicatorInfo
getMissingIndicator={indicator.getMissingIndicator}
/>
)}
Expand Down
7 changes: 4 additions & 3 deletions src/components/listview/List/ListItemBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ const ListItemBody: FC<ListItemBodyProps> = ({
{listOptions.showMediaInfo !== false && !enableSideMediaInfo && (
<PrimaryMediaInfo
className='secondary listItemMediaInfo listItemBodyText'
infoclass='mediaInfoText'
item={item}
isEpisodeTitleEnabled={true}
isOriginalAirDateEnabled={true}
isCaptionIndicatorEnabled={true}
showEpisodeTitleInfo
showOriginalAirDateInfo
showCaptionIndicatorInfo
getMissingIndicator={getMissingIndicator}
/>
)}
Expand Down
1 change: 1 addition & 0 deletions src/components/listview/listview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

.listItemMediaInfo {
align-items: center;
margin-right: 1em;
}

.listItem {
Expand Down
3 changes: 1 addition & 2 deletions src/components/mediainfo/CaptionMediaInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ interface CaptionMediaInfoProps {
const CaptionMediaInfo: FC<CaptionMediaInfoProps> = ({ className }) => {
const cssClass = classNames(
'mediaInfoItem',
'mediaInfoText',
'closedCaptionMediaInfoText',
className
);

return (
<Box className={cssClass}>
<ClosedCaptionIcon fontSize={'small'} />
<ClosedCaptionIcon />
</Box>
);
};
Expand Down
1 change: 0 additions & 1 deletion src/components/mediainfo/EndsAt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ interface EndsAtProps {
const EndsAt: FC<EndsAtProps> = ({ runTimeTicks, className }) => {
const cssClass = classNames(
'mediaInfoItem',
'mediaInfoText',
'endsAt',
className
);
Expand Down
31 changes: 22 additions & 9 deletions src/components/mediainfo/MediaInfoItem.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
import React, { type FC } from 'react';
import Box from '@mui/material/Box';
import Link from '@mui/material/Link';
import classNames from 'classnames';
import type { MiscInfo } from 'types/mediaInfoItem';

interface MediaInfoItemProps {
className?: string;
miscInfo?: MiscInfo ;
miscInfo: MiscInfo ;

}

const MediaInfoItem: FC<MediaInfoItemProps> = ({ className, miscInfo }) => {
const cssClass = classNames(
'mediaInfoItem',
'mediaInfoText',
className,
miscInfo?.cssClass
);
const { text, textAction, cssClass, type } = miscInfo;

const renderText = () => {
if (textAction) {
return (
<Link
className={classNames(textAction.cssClass, className)}
href={textAction.url}
title={textAction.title}
color='inherit'
>
{textAction.title}
</Link>
);
} else {
return text;
}
};

return (
<Box className={cssClass}>
{miscInfo?.text}
<Box className={classNames('mediaInfoItem', cssClass, type, className)}>
{renderText()}
</Box>
);
};
Expand Down
49 changes: 49 additions & 0 deletions src/components/mediainfo/MediaInfoStats.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React, { type FC } from 'react';
import classNames from 'classnames';
import Box from '@mui/material/Box';
import useMediaInfoStats from './useMediaInfoStats';

import MediaInfoItem from './MediaInfoItem';
import type { ItemDto } from 'types/base/models/item-dto';
import type { MiscInfo } from 'types/mediaInfoItem';
import type { MediaInfoStatsOpts } from './type';

interface MediaInfoStatsProps extends MediaInfoStatsOpts {
className?: string;
infoclass?: string;
item: ItemDto;
}

const MediaInfoStats: FC<MediaInfoStatsProps> = ({
className,
infoclass,
item,
showResolutionInfo,
showVideoStreamCodecInfo,
showAudoChannelInfo,
showAudioStreamCodecInfo,
showDateAddedInfo
}) => {
const mediaInfoStats = useMediaInfoStats({
item,
showResolutionInfo,
showVideoStreamCodecInfo,
showAudoChannelInfo,
showAudioStreamCodecInfo,
showDateAddedInfo
});

const cssClass = classNames(className);

const renderMediaInfo = (info: MiscInfo, index: number) => (
<MediaInfoItem key={index} className={infoclass} miscInfo={info} />
);

return (
<Box className={cssClass}>
{mediaInfoStats.map((info, index) => renderMediaInfo(info, index))}
</Box>
);
};

export default MediaInfoStats;
109 changes: 61 additions & 48 deletions src/components/mediainfo/PrimaryMediaInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,59 @@ import EndsAt from './EndsAt';
import { ItemMediaKind } from 'types/base/models/item-media-kind';
import type { ItemDto } from 'types/base/models/item-dto';
import type { MiscInfo } from 'types/mediaInfoItem';
import type { PrimaryInfoOpts } from './type';

interface PrimaryMediaInfoProps {
interface PrimaryMediaInfoProps extends PrimaryInfoOpts {
className?: string;
infoclass?: string;
item: ItemDto;
isYearEnabled?: boolean;
isContainerEnabled?: boolean;
isEpisodeTitleEnabled?: boolean;
isCriticRatingEnabled?: boolean;
isEndsAtEnabled?: boolean;
isOriginalAirDateEnabled?: boolean;
isRuntimeEnabled?: boolean;
isProgramIndicatorEnabled?: boolean;
isEpisodeTitleIndexNumberEnabled?: boolean;
isOfficialRatingEnabled?: boolean;
isStarRatingEnabled?: boolean;
isCaptionIndicatorEnabled?: boolean;
isMissingIndicatorEnabled?: boolean;
getMissingIndicator: () => React.JSX.Element | null
showStarRatingInfo?: boolean;
showCaptionIndicatorInfo?: boolean;
showCriticRatingInfo?: boolean;
showEndsAtInfo?: boolean;
getMissingIndicator?: () => React.JSX.Element | null;
}

const PrimaryMediaInfo: FC<PrimaryMediaInfoProps> = ({
className,
infoclass,
item,
isYearEnabled = false,
isContainerEnabled = false,
isEpisodeTitleEnabled = false,
isCriticRatingEnabled = false,
isEndsAtEnabled = false,
isOriginalAirDateEnabled = false,
isRuntimeEnabled = false,
isProgramIndicatorEnabled = false,
isEpisodeTitleIndexNumberEnabled = false,
isOfficialRatingEnabled = false,
isStarRatingEnabled = false,
isCaptionIndicatorEnabled = false,
isMissingIndicatorEnabled = false,
showYearInfo,
showAudioContainerInfo,
showEpisodeTitleInfo,
showOriginalAirDateInfo,
showFolderRuntimeInfo,
showRuntimeInfo,
showItemCountInfo,
showSeriesTimerInfo,
showStartDateInfo,
showProgramIndicatorInfo,
includeEpisodeTitleIndexNumber,
showOfficialRatingInfo,
showVideo3DFormatInfo,
showPhotoSizeInfo,
showStarRatingInfo = false,
showCaptionIndicatorInfo = false,
showCriticRatingInfo = false,
showEndsAtInfo = false,
getMissingIndicator
}) => {
const miscInfo = usePrimaryMediaInfo({
item,
isYearEnabled,
isContainerEnabled,
isEpisodeTitleEnabled,
isOriginalAirDateEnabled,
isRuntimeEnabled,
isProgramIndicatorEnabled,
isEpisodeTitleIndexNumberEnabled,
isOfficialRatingEnabled
showYearInfo,
showAudioContainerInfo,
showEpisodeTitleInfo,
showOriginalAirDateInfo,
showFolderRuntimeInfo,
showRuntimeInfo,
showItemCountInfo,
showSeriesTimerInfo,
showStartDateInfo,
showProgramIndicatorInfo,
includeEpisodeTitleIndexNumber,
showOfficialRatingInfo,
showVideo3DFormatInfo,
showPhotoSizeInfo
});
const {
StartDate,
Expand All @@ -72,32 +77,40 @@ const PrimaryMediaInfo: FC<PrimaryMediaInfoProps> = ({

const cssClass = classNames(className);

const renderMediaInfo = (info: MiscInfo | undefined, index: number) => (
<MediaInfoItem key={index} miscInfo={info} />
const renderMediaInfo = (info: MiscInfo, index: number) => (
<MediaInfoItem key={index} className={infoclass} miscInfo={info} />
);

return (
<Box className={cssClass}>
{miscInfo.map((info, index) => renderMediaInfo(info, index))}

{isStarRatingEnabled && CommunityRating && (
<StarIcons communityRating={CommunityRating} />
{showStarRatingInfo && CommunityRating && (
<StarIcons
className={infoclass}
communityRating={CommunityRating}
/>
)}

{HasSubtitles && isCaptionIndicatorEnabled && <CaptionMediaInfo />}
{showCaptionIndicatorInfo && HasSubtitles && (
<CaptionMediaInfo className={infoclass} />
)}

{CriticRating && isCriticRatingEnabled && (
<CriticRatingMediaInfo criticRating={CriticRating} />
{showCriticRatingInfo && CriticRating && (
<CriticRatingMediaInfo
className={infoclass}
criticRating={CriticRating}
/>
)}

{isEndsAtEnabled
{showEndsAtInfo
&& MediaType === ItemMediaKind.Video
&& RunTimeTicks
&& !StartDate && <EndsAt runTimeTicks={RunTimeTicks} />}

{isMissingIndicatorEnabled && (
getMissingIndicator()
&& !StartDate && (
<EndsAt className={infoclass} runTimeTicks={RunTimeTicks} />
)}

{getMissingIndicator?.()}
</Box>
);
};
Expand Down
55 changes: 55 additions & 0 deletions src/components/mediainfo/SecondaryMediaInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React, { type FC } from 'react';
import classNames from 'classnames';
import Box from '@mui/material/Box';
import useSecondaryMediaInfo from './useSecondaryMediaInfo';
import useIndicator from 'components/indicators/useIndicator';
import MediaInfoItem from './MediaInfoItem';
import type { ItemDto } from 'types/base/models/item-dto';
import { MiscInfo } from 'types/mediaInfoItem';
import type { SecondaryInfoOpts } from './type';

interface SecondaryMediaInfoProps extends SecondaryInfoOpts {
className?: string;
infoclass?: string;
item: ItemDto;
showTimerIndicatorInfo?: boolean;
}

const SecondaryMediaInfo: FC<SecondaryMediaInfoProps> = ({
className,
infoclass,
item,
showProgramTimeInfo,
showStartDateInfo,
showChannelNumberInfo,
showChannelInfo,
channelInteractive,
showTimerIndicatorInfo = false
}) => {
const miscInfo = useSecondaryMediaInfo({
item,
showProgramTimeInfo,
showStartDateInfo,
showChannelNumberInfo,
showChannelInfo,
channelInteractive
});

const indicator = useIndicator(item);

const cssClass = classNames(className);

const renderMediaInfo = (info: MiscInfo, index: number) => (
<MediaInfoItem key={index} className={infoclass} miscInfo={info} />
);

return (
<Box className={cssClass}>
{miscInfo.map((info, index) => renderMediaInfo(info, index))}

{showTimerIndicatorInfo !== false && indicator.getTimerIndicator()}
</Box>
);
};

export default SecondaryMediaInfo;
10 changes: 6 additions & 4 deletions src/components/mediainfo/StarIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ const StarIcons: FC<StarIconsProps> = ({ className, communityRating }) => {
const theme = useTheme();
const cssClass = classNames(
'mediaInfoItem',
'mediaInfoText',
'starRatingContainer',
className
);

return (
<Box className={cssClass}>
<StarIcon fontSize={'small'} sx={{
color: theme.palette.starIcon.main
}} />
<StarIcon
fontSize={'small'}
sx={{
color: theme.palette.starIcon.main
}}
/>
{communityRating.toFixed(1)}
</Box>
);
Expand Down
Loading
Loading