use decode_stream instead of pako

This commit is contained in:
nklhrstv 2022-06-27 17:07:58 +03:00
parent 874abf6ffa
commit 03b5f1fa9b
3 changed files with 8 additions and 6 deletions

View file

@ -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",

View file

@ -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'
};

View file

@ -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;