diff --git a/src/common/MetaItem/MetaItem.js b/src/common/MetaItem/MetaItem.js index 5656ea6da..82bbcbb16 100644 --- a/src/common/MetaItem/MetaItem.js +++ b/src/common/MetaItem/MetaItem.js @@ -12,10 +12,32 @@ const Multiselect = require('stremio/common/Multiselect'); const useBinaryState = require('stremio/common/useBinaryState'); const { ICON_FOR_TYPE } = require('stremio/common/CONSTANTS'); const styles = require('./styles'); +const UrlUtils = require('url'); +const CONSTANTS = require('stremio/common/CONSTANTS'); -const MetaItem = React.memo(({ className, type, name, poster, posterShape, posterChangeCursor, progress, newVideos, options, deepLinks, dataset, optionOnSelect, onDismissClick, onPlayClick, watched, ...props }) => { +const MetaItem = React.memo(({ className, type, name, poster, posterShape, posterChangeCursor, progress, newVideos, options, deepLinks, dataset, optionOnSelect, onDismissClick, onPlayClick, watched, links, ...props }) => { const { t } = useTranslation(); const [menuOpen, onMenuOpen, onMenuClose] = useBinaryState(false); + const imdbLink = React.useMemo(() => { + if (!Array.isArray(links)) { + return null; + } + + const imdbLink = links.find((link) => { + if (!link || typeof link.category !== 'string' || typeof link.url !== 'string') { + return false; + } + + const { hostname } = UrlUtils.parse(link.url); + return link.category === CONSTANTS.IMDB_LINK_CATEGORY && hostname === 'imdb.com'; + }); + + return imdbLink ? { + label: imdbLink.name, + href: `https://www.stremio.com/warning#${encodeURIComponent(imdbLink.url)}` + } : null; + }, [links]); + const href = React.useMemo(() => { return deepLinks ? typeof deepLinks.player === 'string' ? @@ -130,6 +152,15 @@ const MetaItem = React.memo(({ className, type, name, poster, posterShape, poste