@stremio/stremio-video 0.0.38 → 0.0.39-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stremio/stremio-video",
3
- "version": "0.0.38",
3
+ "version": "0.0.39-beta.3",
4
4
  "description": "Abstraction layer on top of different media players",
5
5
  "author": "Smart Code OOD",
6
6
  "main": "src/index.js",
@@ -0,0 +1,7 @@
1
+ var url = require('url');
2
+
3
+ function destroyHLSConverter(streamingServerURL, id) {
4
+ return fetch(url.resolve(streamingServerURL, '/hlsv2/' + encodeURIComponent(id) + '/destroy'));
5
+ }
6
+
7
+ module.exports = destroyHLSConverter;
@@ -6,6 +6,7 @@ var deepFreeze = require('deep-freeze');
6
6
  var mediaCapabilities = require('../mediaCapabilities');
7
7
  var convertStream = require('./convertStream');
8
8
  var fetchVideoParams = require('./fetchVideoParams');
9
+ var destroyHLSConverter = require('./destroyHLSConverter');
9
10
  var supportsTranscoding = require('../supportsTranscoding');
10
11
  var ERROR = require('../error');
11
12
 
@@ -27,6 +28,7 @@ function withStreamingServer(Video) {
27
28
 
28
29
  var self = this;
29
30
  var loadArgs = null;
31
+ var hlsConverterId = null;
30
32
  var loaded = false;
31
33
  var actionsQueue = [];
32
34
  var videoParams = null;
@@ -141,6 +143,7 @@ function withStreamingServer(Video) {
141
143
  mediaURL: mediaURL,
142
144
  infoHash: infoHash,
143
145
  fileIdx: fileIdx,
146
+ hlsConverterId: null,
144
147
  stream: {
145
148
  url: mediaURL
146
149
  }
@@ -167,6 +170,7 @@ function withStreamingServer(Video) {
167
170
  mediaURL: mediaURL,
168
171
  infoHash: infoHash,
169
172
  fileIdx: fileIdx,
173
+ hlsConverterId: id,
170
174
  stream: {
171
175
  url: url.resolve(commandArgs.streamingServerURL, '/hlsv2/' + id + '/master.m3u8?' + queryParams.toString()),
172
176
  subtitles: Array.isArray(commandArgs.stream.subtitles) ?
@@ -201,6 +205,7 @@ function withStreamingServer(Video) {
201
205
  stream: result.stream
202
206
  })
203
207
  });
208
+ hlsConverterId = result.hlsConverterId;
204
209
  loaded = true;
205
210
  flushActionsQueue();
206
211
  fetchVideoParams(commandArgs.streamingServerURL, result.mediaURL, result.infoHash, result.fileIdx, commandArgs.stream.behaviorHints)
@@ -274,6 +279,13 @@ function withStreamingServer(Video) {
274
279
  return true;
275
280
  }
276
281
  case 'unload': {
282
+ if (loadArgs && hlsConverterId !== null) {
283
+ destroyHLSConverter(loadArgs.streamingServerURL, hlsConverterId).catch(function(error) {
284
+ // eslint-disable-next-line no-console
285
+ console.error(error);
286
+ });
287
+ }
288
+ hlsConverterId = null;
277
289
  loadArgs = null;
278
290
  loaded = false;
279
291
  actionsQueue = [];