diff --git a/package.json b/package.json index 087d35e27..fa93ef7da 100755 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "lodash.debounce": "4.0.8", "lodash.isequal": "4.5.0", "lodash.throttle": "4.1.1", - "pako": "1.0.11", "prop-types": "15.7.2", "react": "16.12.0", "react-dom": "16.12.0", diff --git a/src/routes/Player/usePlayer.js b/src/routes/Player/usePlayer.js index 58270f286..0e728b51f 100644 --- a/src/routes/Player/usePlayer.js +++ b/src/routes/Player/usePlayer.js @@ -1,7 +1,6 @@ // Copyright (C) 2017-2022 Smart code 203358507 const React = require('react'); -const pako = require('pako'); const { useServices } = require('stremio/services'); const { useModelState } = require('stremio/common'); @@ -47,13 +46,14 @@ const map = (player) => ({ const usePlayer = (urlParams) => { const { core } = useServices(); const action = React.useMemo(() => { - try { + const stream = core.transport.decodeStream(urlParams.stream); + if (stream !== null) { return { action: 'Load', args: { model: 'Player', args: { - stream: JSON.parse(pako.inflate(atob(urlParams.stream), { to: 'string' })), + stream, streamRequest: typeof urlParams.streamTransportUrl === 'string' && typeof urlParams.type === 'string' && typeof urlParams.videoId === 'string' ? { base: urlParams.streamTransportUrl, @@ -90,7 +90,7 @@ const usePlayer = (urlParams) => { } } }; - } catch (e) { + } else { return { action: 'Unload' }; diff --git a/src/services/Core/CoreTransport.js b/src/services/Core/CoreTransport.js index 0e220c23d..95a8cff34 100644 --- a/src/services/Core/CoreTransport.js +++ b/src/services/Core/CoreTransport.js @@ -1,7 +1,7 @@ // Copyright (C) 2017-2022 Smart code 203358507 const EventEmitter = require('eventemitter3'); -const { default: initialize_api, initialize_runtime, get_state, get_debug_state, dispatch, analytics } = require('@stremio/stremio-core-web'); +const { default: initialize_api, initialize_runtime, get_state, get_debug_state, dispatch, analytics, decode_stream } = require('@stremio/stremio-core-web'); function CoreTransport() { const events = new EventEmitter(); @@ -54,6 +54,9 @@ function CoreTransport() { console.error('CoreTransport', error); } }; + this.decodeStream = function(stream) { + return decode_stream(stream); + }; } module.exports = CoreTransport;