fix(streams): copy stream link returns streamable url

feat(streams): add copy download link

Signed-off-by: Lachezar Lechev <lachezar@ambire.com>
This commit is contained in:
Lachezar Lechev 2026-01-15 17:58:43 +02:00
parent 9966ae43d5
commit e11366b374
No known key found for this signature in database
GPG key ID: 69BDCB3ED8CE8037

View file

@ -86,6 +86,10 @@ const Stream = ({ className, videoId, videoReleased, addonName, name, descriptio
}, [href, deepLinks]);
const streamLink = React.useMemo(() => {
return deepLinks?.externalPlayer?.streaming;
}, [deepLinks]);
const downloadLink = React.useMemo(() => {
return deepLinks?.externalPlayer?.download;
}, [deepLinks]);
@ -116,6 +120,28 @@ const Stream = ({ className, videoId, videoReleased, addonName, name, descriptio
}
}, [props.onClick, profile.settings, markVideoAsWatched]);
const copyDownloadLink = React.useCallback((event) => {
event.preventDefault();
closeMenu();
if (downloadLink) {
navigator.clipboard.writeText(downloadLink)
.then(() => {
toast.show({
type: 'success',
title: t('PLAYER_COPY_DOWNLOAD_SUCCESS'),
timeout: 4000
});
})
.catch(() => {
toast.show({
type: 'error',
title: t('PLAYER_COPY_DOWNLOAD_ERROR'),
timeout: 4000,
});
});
}
}, [downloadLink]);
const copyStreamLink = React.useCallback((event) => {
event.preventDefault();
closeMenu();
@ -195,6 +221,13 @@ const Stream = ({ className, videoId, videoReleased, addonName, name, descriptio
<div className={styles['context-menu-option-label']}>{t('CTX_COPY_STREAM_LINK')}</div>
</Button>
}
{
downloadLink &&
<Button className={styles['context-menu-option-container']} title={t('CTX_DOWNLOAD_STREAM_LINK')} onClick={copyDownloadLink}>
<Icon className={styles['menu-icon']} name={'download'} />
<div className={styles['context-menu-option-label']}>{t('CTX_COPY_DOWNLOAD_LINK')}</div>
</Button>
}
</div>
);
}, [copyStreamLink, onClick]);