mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 17:15:48 +00:00
Merge 097857d27c into 89515a2a75
This commit is contained in:
commit
c1fd89d550
4 changed files with 90 additions and 14 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
|||
<div className={styles['context-menu-option-label']}>{t('CTX_COPY_STREAM_LINK')}</div>
|
||||
</Button>
|
||||
}
|
||||
{
|
||||
magnetLink &&
|
||||
<Button className={styles['context-menu-option-container']} title={t('CTX_COPY_MAGNET_LINK')} onClick={copyMagnetLink}>
|
||||
<Icon className={styles['menu-icon']} name={'magnet-link'} />
|
||||
<div className={styles['context-menu-option-label']}>{t('CTX_COPY_MAGNET_LINK')}</div>
|
||||
</Button>
|
||||
}
|
||||
{
|
||||
downloadLink &&
|
||||
<Button className={styles['context-menu-option-container']} title={t('CTX_DOWNLOAD_VIDEO')} onClick={copyDownloadLink}>
|
||||
|
|
@ -267,6 +304,7 @@ Stream.propTypes = {
|
|||
player: PropTypes.string,
|
||||
externalPlayer: PropTypes.shape({
|
||||
download: PropTypes.string,
|
||||
magnet: PropTypes.string,
|
||||
streaming: PropTypes.string,
|
||||
playlist: PropTypes.string,
|
||||
fileName: PropTypes.string,
|
||||
|
|
|
|||
|
|
@ -14,13 +14,17 @@ const OptionsMenu = ({ className, stream, playbackDevices, extraSubtitlesTracks,
|
|||
const { core } = useServices();
|
||||
const platform = usePlatform();
|
||||
const toast = useToast();
|
||||
const [streamingUrl, downloadUrl] = React.useMemo(() => {
|
||||
const [streamingUrl, downloadUrl, magnetUrl] = React.useMemo(() => {
|
||||
return stream !== null ?
|
||||
stream.deepLinks &&
|
||||
stream.deepLinks.externalPlayer &&
|
||||
[stream.deepLinks.externalPlayer.streaming, stream.deepLinks.externalPlayer.download]
|
||||
[
|
||||
stream.deepLinks.externalPlayer.streaming,
|
||||
stream.deepLinks.externalPlayer.download,
|
||||
stream.deepLinks.externalPlayer.magnet,
|
||||
]
|
||||
:
|
||||
[null, null];
|
||||
[null, null, null];
|
||||
}, [stream]);
|
||||
const externalDevices = React.useMemo(() => {
|
||||
return playbackDevices.filter(({ type }) => type === 'external');
|
||||
|
|
@ -53,11 +57,33 @@ const OptionsMenu = ({ className, stream, playbackDevices, extraSubtitlesTracks,
|
|||
});
|
||||
}
|
||||
}, [streamingUrl, downloadUrl]);
|
||||
const onDownloadVideoButtonClick = React.useCallback(() => {
|
||||
if (downloadUrl || streamingUrl ) {
|
||||
platform.openExternal(downloadUrl || streamingUrl);
|
||||
const onCopyMagnetButtonClick = React.useCallback(() => {
|
||||
if (magnetUrl) {
|
||||
navigator.clipboard.writeText(magnetUrl)
|
||||
.then(() => {
|
||||
toast.show({
|
||||
type: 'success',
|
||||
title: 'Copied',
|
||||
message: t('PLAYER_COPY_MAGNET_LINK_SUCCESS'),
|
||||
timeout: 3000
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
toast.show({
|
||||
type: 'error',
|
||||
title: t('Error'),
|
||||
message: `${t('PLAYER_COPY_MAGNET_LINK_ERROR')}: ${magnetUrl}`,
|
||||
timeout: 3000
|
||||
});
|
||||
});
|
||||
}
|
||||
}, [streamingUrl, downloadUrl]);
|
||||
}, [magnetUrl]);
|
||||
const onDownloadVideoButtonClick = React.useCallback(() => {
|
||||
if (downloadUrl) {
|
||||
platform.openExternal(downloadUrl);
|
||||
}
|
||||
}, [downloadUrl]);
|
||||
|
||||
const onDownloadSubtitlesClick = React.useCallback(() => {
|
||||
subtitlesTrackUrl && platform.openExternal(subtitlesTrackUrl);
|
||||
|
|
@ -95,7 +121,18 @@ const OptionsMenu = ({ className, stream, playbackDevices, extraSubtitlesTracks,
|
|||
null
|
||||
}
|
||||
{
|
||||
streamingUrl || downloadUrl ?
|
||||
magnetUrl ?
|
||||
<Option
|
||||
icon={'magnet-link'}
|
||||
label={t('CTX_COPY_MAGNET_LINK')}
|
||||
disabled={stream === null}
|
||||
onClick={onCopyMagnetButtonClick}
|
||||
/>
|
||||
:
|
||||
null
|
||||
}
|
||||
{
|
||||
downloadUrl ?
|
||||
<Option
|
||||
icon={'download'}
|
||||
label={t('CTX_DOWNLOAD_VIDEO')}
|
||||
|
|
|
|||
Loading…
Reference in a new issue