diff --git a/packages/common/src/utils/media.ts b/packages/common/src/utils/media.ts index 84413df27..cc0fa17bc 100644 --- a/packages/common/src/utils/media.ts +++ b/packages/common/src/utils/media.ts @@ -1,8 +1,6 @@ import type { Playlist, PlaylistItem } from '../../types/playlist'; import { CONTENT_TYPE } from '../constants'; -import { formatDuration, formatVideoSchedule } from './formatting'; - type RequiredProperties = T & Required>; type DeprecatedPlaylistItem = { @@ -51,39 +49,3 @@ export const getLegacySeriesPlaylistIdFromEpisodeTags = (item: PlaylistItem | un export const isLiveChannel = (item: PlaylistItem): item is RequiredProperties => item.contentType?.toLowerCase() === CONTENT_TYPE.liveChannel && !!item.liveChannelsId; - -export const createVideoMetadata = (media: PlaylistItem, episodesLabel?: string) => { - const metaData = []; - const duration = formatDuration(media.duration); - - if (media.pubdate) metaData.push(String(new Date(media.pubdate * 1000).getFullYear())); - if (!episodesLabel && duration) metaData.push(duration); - if (episodesLabel) metaData.push(episodesLabel); - if (media.genre) metaData.push(media.genre); - if (media.rating) metaData.push(media.rating); - - return metaData; -}; - -export const createPlaylistMetadata = (playlist: Playlist, episodesLabel?: string) => { - const metaData = []; - - if (episodesLabel) metaData.push(episodesLabel); - if (playlist.genre) metaData.push(playlist.genre as string); - if (playlist.rating) metaData.push(playlist.rating as string); - - return metaData; -}; - -export const createLiveEventMetadata = (media: PlaylistItem, locale: string) => { - const metaData = []; - const scheduled = formatVideoSchedule(locale, media.scheduledStart, media.scheduledEnd); - const duration = formatDuration(media.duration); - - if (scheduled) metaData.push(scheduled); - if (duration) metaData.push(duration); - if (media.genre) metaData.push(media.genre); - if (media.rating) metaData.push(media.rating); - - return metaData; -}; diff --git a/packages/common/src/utils/metadata.ts b/packages/common/src/utils/metadata.ts new file mode 100644 index 000000000..3d7c12d90 --- /dev/null +++ b/packages/common/src/utils/metadata.ts @@ -0,0 +1,37 @@ +import type { Playlist, PlaylistItem } from '../../types/playlist'; + +import { formatDuration, formatVideoSchedule } from './formatting'; + +export const createVideoMetadata = (media: PlaylistItem, episodesLabel?: string) => { + const metaData = []; + const duration = formatDuration(media.duration); + + if (media.pubdate) metaData.push(String(new Date(media.pubdate * 1000).getFullYear())); + if (!episodesLabel && duration) metaData.push(duration); + if (episodesLabel) metaData.push(episodesLabel); + if (media.genre) metaData.push(media.genre); + if (media.rating) metaData.push(media.rating); + + return metaData; +}; +export const createPlaylistMetadata = (playlist: Playlist, episodesLabel?: string) => { + const metaData = []; + + if (episodesLabel) metaData.push(episodesLabel); + if (playlist.genre) metaData.push(playlist.genre as string); + if (playlist.rating) metaData.push(playlist.rating as string); + + return metaData; +}; +export const createLiveEventMetadata = (media: PlaylistItem, locale: string) => { + const metaData = []; + const scheduled = formatVideoSchedule(locale, media.scheduledStart, media.scheduledEnd); + const duration = formatDuration(media.duration); + + if (scheduled) metaData.push(scheduled); + if (duration) metaData.push(duration); + if (media.genre) metaData.push(media.genre); + if (media.rating) metaData.push(media.rating); + + return metaData; +}; diff --git a/packages/ui-react/src/pages/LegacySeries/LegacySeries.tsx b/packages/ui-react/src/pages/LegacySeries/LegacySeries.tsx index 74b3ca2c5..03bff477b 100644 --- a/packages/ui-react/src/pages/LegacySeries/LegacySeries.tsx +++ b/packages/ui-react/src/pages/LegacySeries/LegacySeries.tsx @@ -7,7 +7,7 @@ import type { PlaylistItem } from '@jwp/ott-common/types/playlist'; import { useWatchHistoryStore } from '@jwp/ott-common/src/stores/WatchHistoryStore'; import { useConfigStore } from '@jwp/ott-common/src/stores/ConfigStore'; import { useAccountStore } from '@jwp/ott-common/src/stores/AccountStore'; -import { createPlaylistMetadata, createVideoMetadata } from '@jwp/ott-common/src/utils/media'; +import { createPlaylistMetadata, createVideoMetadata } from '@jwp/ott-common/src/utils/metadata'; import { formatSeriesMetaString } from '@jwp/ott-common/src/utils/formatting'; import { legacySeriesURL } from '@jwp/ott-common/src/utils/urlFormatting'; import useEntitlement from '@jwp/ott-hooks-react/src/useEntitlement'; diff --git a/packages/ui-react/src/pages/ScreenRouting/mediaScreens/MediaEvent/MediaEvent.tsx b/packages/ui-react/src/pages/ScreenRouting/mediaScreens/MediaEvent/MediaEvent.tsx index 2c942c37e..d6da6c8f2 100644 --- a/packages/ui-react/src/pages/ScreenRouting/mediaScreens/MediaEvent/MediaEvent.tsx +++ b/packages/ui-react/src/pages/ScreenRouting/mediaScreens/MediaEvent/MediaEvent.tsx @@ -7,7 +7,7 @@ import type { PlaylistItem } from '@jwp/ott-common/types/playlist'; import { useConfigStore } from '@jwp/ott-common/src/stores/ConfigStore'; import { useAccountStore } from '@jwp/ott-common/src/stores/AccountStore'; import { MediaStatus } from '@jwp/ott-common/src/utils/liveEvent'; -import { createLiveEventMetadata } from '@jwp/ott-common/src/utils/media'; +import { createLiveEventMetadata } from '@jwp/ott-common/src/utils/metadata'; import { mediaURL } from '@jwp/ott-common/src/utils/urlFormatting'; import { generateMovieJSONLD } from '@jwp/ott-common/src/utils/structuredData'; import useMedia from '@jwp/ott-hooks-react/src/useMedia'; diff --git a/packages/ui-react/src/pages/ScreenRouting/mediaScreens/MediaMovie/MediaMovie.tsx b/packages/ui-react/src/pages/ScreenRouting/mediaScreens/MediaMovie/MediaMovie.tsx index 95af81bb0..dd3d5df03 100644 --- a/packages/ui-react/src/pages/ScreenRouting/mediaScreens/MediaMovie/MediaMovie.tsx +++ b/packages/ui-react/src/pages/ScreenRouting/mediaScreens/MediaMovie/MediaMovie.tsx @@ -6,7 +6,7 @@ import { shallow } from '@jwp/ott-common/src/utils/compare'; import type { PlaylistItem } from '@jwp/ott-common/types/playlist'; import { useConfigStore } from '@jwp/ott-common/src/stores/ConfigStore'; import { useAccountStore } from '@jwp/ott-common/src/stores/AccountStore'; -import { createVideoMetadata } from '@jwp/ott-common/src/utils/media'; +import { createVideoMetadata } from '@jwp/ott-common/src/utils/metadata'; import { mediaURL } from '@jwp/ott-common/src/utils/urlFormatting'; import { generateMovieJSONLD } from '@jwp/ott-common/src/utils/structuredData'; import useMedia from '@jwp/ott-hooks-react/src/useMedia'; diff --git a/packages/ui-react/src/pages/ScreenRouting/mediaScreens/MediaSeries/MediaSeries.tsx b/packages/ui-react/src/pages/ScreenRouting/mediaScreens/MediaSeries/MediaSeries.tsx index 8d067e2c3..46beef251 100644 --- a/packages/ui-react/src/pages/ScreenRouting/mediaScreens/MediaSeries/MediaSeries.tsx +++ b/packages/ui-react/src/pages/ScreenRouting/mediaScreens/MediaSeries/MediaSeries.tsx @@ -10,7 +10,7 @@ import { useConfigStore } from '@jwp/ott-common/src/stores/ConfigStore'; import { useAccountStore } from '@jwp/ott-common/src/stores/AccountStore'; import { generateEpisodeJSONLD } from '@jwp/ott-common/src/utils/structuredData'; import { getEpisodesInSeason, getFiltersFromSeries } from '@jwp/ott-common/src/utils/series'; -import { createVideoMetadata } from '@jwp/ott-common/src/utils/media'; +import { createVideoMetadata } from '@jwp/ott-common/src/utils/metadata'; import { formatSeriesMetaString } from '@jwp/ott-common/src/utils/formatting'; import { buildLegacySeriesUrlFromMediaItem, mediaURL } from '@jwp/ott-common/src/utils/urlFormatting'; import { VideoProgressMinMax } from '@jwp/ott-common/src/constants';