mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 03:22:11 +00:00
feat: full deeplink support for shell
This commit is contained in:
parent
b3bd68eb32
commit
41546d65d2
3 changed files with 15 additions and 6 deletions
|
|
@ -102,12 +102,18 @@ const App = () => {
|
||||||
// Handle shell events
|
// Handle shell events
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const onOpenMedia = (data) => {
|
const onOpenMedia = (data) => {
|
||||||
if (data.startsWith('stremio:///')) return;
|
try {
|
||||||
if (data.startsWith('stremio://')) {
|
const { protocol, hostname, pathname, searchParams } = new URL(data);
|
||||||
const transportUrl = data.replace('stremio://', 'https://');
|
if (protocol === CONSTANTS.PROTOCOL) {
|
||||||
if (URL.canParse(transportUrl)) {
|
if (hostname.length) {
|
||||||
window.location.href = `#/addons?addon=${encodeURIComponent(transportUrl)}`;
|
const transportUrl = `https://${hostname}${pathname}`;
|
||||||
|
window.location.href = `#/addons?addon=${encodeURIComponent(transportUrl)}`;
|
||||||
|
} else {
|
||||||
|
window.location.href = `#${pathname}?${searchParams.toString()}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to open media:", e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,8 @@ const EXTERNAL_PLAYERS = [
|
||||||
|
|
||||||
const WHITELISTED_HOSTS = ['stremio.com', 'strem.io', 'stremio.zendesk.com', 'google.com', 'youtube.com', 'twitch.tv', 'twitter.com', 'x.com', 'netflix.com', 'adex.network', 'amazon.com', 'forms.gle'];
|
const WHITELISTED_HOSTS = ['stremio.com', 'strem.io', 'stremio.zendesk.com', 'google.com', 'youtube.com', 'twitch.tv', 'twitter.com', 'x.com', 'netflix.com', 'adex.network', 'amazon.com', 'forms.gle'];
|
||||||
|
|
||||||
|
const PROTOCOL = 'stremio:';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
CHROMECAST_RECEIVER_APP_ID,
|
CHROMECAST_RECEIVER_APP_ID,
|
||||||
DEFAULT_STREAMING_SERVER_URL,
|
DEFAULT_STREAMING_SERVER_URL,
|
||||||
|
|
@ -127,4 +129,5 @@ module.exports = {
|
||||||
SUPPORTED_LOCAL_SUBTITLES,
|
SUPPORTED_LOCAL_SUBTITLES,
|
||||||
EXTERNAL_PLAYERS,
|
EXTERNAL_PLAYERS,
|
||||||
WHITELISTED_HOSTS,
|
WHITELISTED_HOSTS,
|
||||||
|
PROTOCOL,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ const routesRegexp = {
|
||||||
urlParamsNames: []
|
urlParamsNames: []
|
||||||
},
|
},
|
||||||
board: {
|
board: {
|
||||||
regexp: /^\/?$/,
|
regexp: /^\/(?:board)?$/,
|
||||||
urlParamsNames: []
|
urlParamsNames: []
|
||||||
},
|
},
|
||||||
discover: {
|
discover: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue