diff --git a/package.json b/package.json index 5d4f8efe3..4a90ceb85 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@babel/runtime": "7.26.0", "@sentry/browser": "8.42.0", "@stremio/stremio-colors": "5.2.0", - "@stremio/stremio-core-web": "0.53.0", + "@stremio/stremio-core-web": "https://stremio.github.io/stremio-core/stremio-core-web/feat/stream-magnet-deeplink/dev/stremio-stremio-core-web-0.53.0.tgz", "@stremio/stremio-icons": "5.8.0", "@stremio/stremio-video": "0.0.70", "a-color-picker": "1.2.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c0a627617..aa3a0d94b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,8 +18,8 @@ importers: specifier: 5.2.0 version: 5.2.0 '@stremio/stremio-core-web': - specifier: 0.53.0 - version: 0.53.0 + specifier: https://stremio.github.io/stremio-core/stremio-core-web/feat/stream-magnet-deeplink/dev/stremio-stremio-core-web-0.53.0.tgz + version: https://stremio.github.io/stremio-core/stremio-core-web/feat/stream-magnet-deeplink/dev/stremio-stremio-core-web-0.53.0.tgz '@stremio/stremio-icons': specifier: 5.8.0 version: 5.8.0 @@ -1120,8 +1120,9 @@ packages: '@stremio/stremio-colors@5.2.0': resolution: {integrity: sha512-dYlPgu9W/H7c9s1zmW5tiDnRenaUa4Hg1QCyOg1lhOcgSfM/bVTi5nnqX+IfvGTTUNA0zgzh8hI3o3miwnZxTg==} - '@stremio/stremio-core-web@0.53.0': - resolution: {integrity: sha512-WwffG8qJsJk4ftR7ToiMWyANnOeF6r8zubMlOGEJaj+d5B23xcYLZlOrYa5zty28DPBhiCtExDkO/yU16Ne97w==} + '@stremio/stremio-core-web@https://stremio.github.io/stremio-core/stremio-core-web/feat/stream-magnet-deeplink/dev/stremio-stremio-core-web-0.53.0.tgz': + resolution: {tarball: https://stremio.github.io/stremio-core/stremio-core-web/feat/stream-magnet-deeplink/dev/stremio-stremio-core-web-0.53.0.tgz} + version: 0.53.0 '@stremio/stremio-icons@5.8.0': resolution: {integrity: sha512-IVUvQbIWfA4YEHCTed7v/sdQJCJ+OOCf84LTWpkE2W6GLQ+15WHcMEJrVkE1X3ekYJnGg3GjT0KLO6tKSU0P4w==} @@ -5870,7 +5871,7 @@ snapshots: '@stremio/stremio-colors@5.2.0': {} - '@stremio/stremio-core-web@0.53.0': + '@stremio/stremio-core-web@https://stremio.github.io/stremio-core/stremio-core-web/feat/stream-magnet-deeplink/dev/stremio-stremio-core-web-0.53.0.tgz': dependencies: '@babel/runtime': 7.24.1 diff --git a/src/routes/MetaDetails/StreamsList/Stream/Stream.js b/src/routes/MetaDetails/StreamsList/Stream/Stream.js index e5a8717cb..c556fa1e2 100644 --- a/src/routes/MetaDetails/StreamsList/Stream/Stream.js +++ b/src/routes/MetaDetails/StreamsList/Stream/Stream.js @@ -93,6 +93,10 @@ const Stream = ({ className, videoId, videoReleased, addonName, name, descriptio return deepLinks?.externalPlayer?.download; }, [deepLinks]); + const magnetLink = React.useMemo(() => { + return deepLinks?.externalPlayer?.magnet; + }, [deepLinks]); + const markVideoAsWatched = React.useCallback(() => { if (typeof videoId === 'string') { core.transport.dispatch({ @@ -106,6 +110,10 @@ const Stream = ({ className, videoId, videoReleased, addonName, name, descriptio }, [videoId, videoReleased]); const onClick = React.useCallback((event) => { + if (event.nativeEvent.togglePopupPrevented) { + return; + } + if (profile.settings.playerType !== null) { markVideoAsWatched(); toast.show({ @@ -120,6 +128,28 @@ const Stream = ({ className, videoId, videoReleased, addonName, name, descriptio } }, [props.onClick, profile.settings, markVideoAsWatched]); + const copyMagnetLink = React.useCallback((event) => { + event.preventDefault(); + closeMenu(); + if (magnetLink) { + navigator.clipboard.writeText(magnetLink) + .then(() => { + toast.show({ + type: 'success', + title: t('PLAYER_COPY_MAGNET_LINK_SUCCESS'), + timeout: 4000 + }); + }) + .catch(() => { + toast.show({ + type: 'error', + title: t('PLAYER_COPY_MAGNET_LINK_ERROR'), + timeout: 4000, + }); + }); + } + }, [magnetLink]); + const copyDownloadLink = React.useCallback((event) => { event.preventDefault(); closeMenu(); @@ -221,6 +251,13 @@ const Stream = ({ className, videoId, videoReleased, addonName, name, descriptio
{t('CTX_COPY_STREAM_LINK')}
} + { + magnetLink && + + } { downloadLink &&