Skip to content

Commit 7081dbf

Browse files
authored
0.5.0 (#134)
* Update dependencies * Fix Linter issues * Downgrade eslint version * Drop Node.js v8 support
1 parent 1edb713 commit 7081dbf

21 files changed

+2974
-6026
lines changed

.github/workflows/nodejs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
node-version: [8.x, 10.x, 12.x, 14.x]
12+
node-version: [10.x, 12.x, 14.x]
1313

1414
steps:
1515
- uses: actions/checkout@v1

CHANGELOG.MD

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# 0.5.0
2+
* Added Node.js v14 LTS Support
3+
* Added Electron 9 support
4+
* Updated dependencies
5+
* Removed UglifyJs and use TerserJs as a default minimizer
6+
* Moved from `master` branch to `main` branch
7+
* Fixed manifest saving issue (only `undefined` string was stored)
8+
* Dropped Node.js v8 support
9+
110
# 0.4.0
211
* Monitor key session state and detect downloaded stream with persistent license
312
* Node.js v10 LTS Support

api/be-methods/downloads/remove-all-unfinished.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ module.exports = function (api, onSuccess, onFailure) {
2222
}
2323
}
2424
Promise.all(promises)
25-
.then(function () {
26-
let promises = [];
27-
for (let i = 0, j = manifestIds.length; i < j; i++) {
28-
promises.push(api.offlineController.removePromise(manifestIds[i]));
29-
}
30-
Promise.all(promises)
31-
.then(function () {
32-
api.subscribersController.unsubscribe(manifestIds);
33-
api.manifestController.removeFromCache(manifestIds);
34-
onSuccess(manifestIds);
35-
}, function (err) {
36-
onFailure(translation.getError(translation.e.downloads.REMOVING_ALL_UNFINISHED_FAILED), err);
37-
});
38-
}, function (err) {
39-
onFailure(translation.getError(translation.e.downloads.REMOVING_ALL_UNFINISHED_FAILED), err);
40-
});
25+
.then(function () {
26+
let promises = [];
27+
for (let i = 0, j = manifestIds.length; i < j; i++) {
28+
promises.push(api.offlineController.removePromise(manifestIds[i]));
29+
}
30+
Promise.all(promises)
31+
.then(function () {
32+
api.subscribersController.unsubscribe(manifestIds);
33+
api.manifestController.removeFromCache(manifestIds);
34+
onSuccess(manifestIds);
35+
}, function (err) {
36+
onFailure(translation.getError(translation.e.downloads.REMOVING_ALL_UNFINISHED_FAILED), err);
37+
});
38+
}, function (err) {
39+
onFailure(translation.getError(translation.e.downloads.REMOVING_ALL_UNFINISHED_FAILED), err);
40+
});
4141
}
4242
});
4343
};

api/controllers/downloads-controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ DownloadsController.prototype.start = function (manifestId, representations, dow
479479
const self = this;
480480
this.downloadStats.start();
481481
const manifest = this._manifestController.getManifestById(manifestId);
482+
482483
if (!manifest) {
483484
onFailure(translation.getError(translation.e.manifests.NOT_FOUND, manifestId));
484485
return;

api/controllers/offline-controller.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ function OfflineController (manifestController) {
2626
OfflineController.prototype.getManifestsList = function (callback) {
2727
dirList(appSettings.getSettings().settingsFolder, true, false)
2828
.then(function (settingsFolderList) {
29-
let manifestList = [];
30-
for (let i = 0, j = settingsFolderList.length; i < j; i++) {
31-
manifestList.push(settingsFolderList[i]);
32-
}
33-
callback(null, manifestList);
34-
}, function (err) {
35-
callback(err)
36-
});
29+
let manifestList = [];
30+
for (let i = 0, j = settingsFolderList.length; i < j; i++) {
31+
manifestList.push(settingsFolderList[i]);
32+
}
33+
callback(null, manifestList);
34+
}, function (err) {
35+
callback(err);
36+
});
3737
};
3838

3939
/**
@@ -60,8 +60,8 @@ OfflineController.prototype.getManifestsListWithInfo = function (callback, full)
6060
}
6161
}
6262
callback(null, newResults);
63-
}, function (err) {
64-
callback(err);
63+
}, function (promisesError) {
64+
callback(promisesError);
6565
});
6666
}
6767
});
@@ -218,7 +218,7 @@ OfflineController.prototype.getManifestDataFile = function (manifestId, callback
218218
*/
219219
OfflineController.prototype.remove = function (manifestId, onSuccess, onFailure) {
220220
const settingsFolder = appSettings.getSettings().settingsFolder + manifestId;
221-
this.getManifestDataFile( manifestId, function (info) {
221+
this.getManifestDataFile(manifestId, function (info) {
222222
if (!info) {
223223
// no manifest data found for manifest, the download has not been started => just remove settings
224224
rmdir(settingsFolder, function (err) {
@@ -232,7 +232,7 @@ OfflineController.prototype.remove = function (manifestId, onSuccess, onFailure)
232232
let folder = info.folder;
233233
if (!folder) {
234234
// use default download folder path
235-
folder = path.resolve(appSettings.getSettings().downloadsFolderPath);
235+
folder = path.resolve(appSettings.getSettings().downloadsFolderPath);
236236
}
237237
const downloadsFolder = folder + '/' + manifestId;
238238
rmdir(downloadsFolder, function (err) {
@@ -311,7 +311,7 @@ OfflineController.prototype.restoreLocalManifest = function (manifestId, onSucce
311311
representations.audio = info.manifest.audio;
312312
representations.text = info.manifest.text;
313313
self._manifestController.saveManifestWithChosenRepresentations(manifestId, representations)
314-
.then(onSuccess, onFailure);
314+
.then(onSuccess, onFailure);
315315
});
316316
};
317317

api/downstream-electron-be.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ const Server = require('./server/server.js');
1313

1414
let DownstreamElectronBE;
1515

16+
function deserialize (serializedJavascript) {
17+
try {
18+
return JSON.parse(serializedJavascript);
19+
} catch (err) {
20+
return {};
21+
}
22+
}
23+
1624
/**
1725
* @constructor
1826
* @namespace DownstreamElectronBE
@@ -182,7 +190,7 @@ DownstreamElectronBE.prototype._getMethod = function (methodName) {
182190
*/
183191
DownstreamElectronBE.prototype._onApiRequest = function (evt, data, target) {
184192
const promiseId = data.promiseId;
185-
const argsObj = data.args || {};
193+
const argsObj = deserialize(data.args) || {};
186194
const method = data.method;
187195
const windowId = data.windowId;
188196
target = windowId;
@@ -224,7 +232,7 @@ DownstreamElectronBE.prototype._serveOfflineContent = function () {
224232
const maxOfflineContentPortRange = appSettings.getSettings().maxOfflineContentPortRange;
225233

226234
this.server = new Server(this.offlineController, this.downloadsController, maxOfflineContentPortRange, this._offlineContentPort);
227-
this.server.serveOfflineContent( function (offlinePort) {
235+
this.server.serveOfflineContent(function (offlinePort) {
228236
self._offlineContentPort = offlinePort;
229237
})
230238

api/downstream-electron-fe.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ const translation = require("./translation/index");
99

1010
let downstreamElectronFE;
1111

12+
function serialize (obj) {
13+
return JSON.stringify(obj);
14+
}
15+
1216
function getWidevinePSSH (info) {
1317
const manifestProtections = info.manifestInfo.protections;
1418
let videoRepresentation = manifestProtections.video[0] || {};
@@ -138,12 +142,12 @@ DownstreamElectronFE.prototype.downloads.createPersistent = function (args, reso
138142
scope.downloads.savePersistent(manifestId, persistentSessionId).then(function () {
139143
if (existingPersistentSessionId) {
140144
scope._persistent.removePersistentSession(existingPersistentSessionId)
141-
.then(function () {
142-
resolve(persistentSessionId);
143-
})
144-
.catch(function () {
145-
resolve(persistentSessionId);
146-
});
145+
.then(function () {
146+
resolve(persistentSessionId);
147+
})
148+
.catch(function () {
149+
resolve(persistentSessionId);
150+
});
147151
} else {
148152
resolve(persistentSessionId);
149153
}
@@ -247,7 +251,7 @@ DownstreamElectronFE.prototype._apiCall = function (method, args, originalMethod
247251
request.promiseId = promiseId;
248252
request.method = method;
249253
request.windowId = this._windowId;
250-
request.args = args;
254+
request.args = serialize(args);
251255
this._send(request);
252256
return promise;
253257
};
@@ -388,7 +392,7 @@ DownstreamElectronFE.prototype._removeSubscribers = function () {
388392
}
389393
}
390394
request.method = 'removeSubscribers';
391-
request.args = [subscribersId];
395+
request.args = serialize([subscribersId]);
392396

393397
this._send(request);
394398
};

api/util/dir-list.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ function dirList (dir, includeFolders, includeFiles) {
6262
resolve(results.filter(function (folderName) {
6363
return typeof folderName !== "undefined"
6464
}));
65-
}, function (err) {
66-
reject(err);
65+
}, function (promiseError) {
66+
reject(promiseError);
6767
});
6868
}
6969
});

api/util/save-file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const fs = require("fs");
44
const path = require("path");
55

66
function saveFile (filePath, fileName, value, callback) {
7-
mkdirp(filePath).then(function (value) {
7+
mkdirp(filePath).then(function () {
88
const fileUrl = path.resolve(filePath + "/" + fileName);
99
fs.writeFile(fileUrl, value, "utf-8", callback);
1010
}, function (error) {

app.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ const path = require('path');
2727
// default value of allowRendererProcessReuse false is deprecated
2828
app.allowRendererProcessReuse = true;
2929

30-
function createWindow () {
30+
function createWindow() {
3131
// eslint-disable-next-line no-process-env
3232
let appDir = path.dirname(process.mainModule.filename) + '/';
3333
// head request parameter test
3434
let useHeadRequest = true;
35-
35+
3636
// let useHeadRequest = false;
3737
downstreamInstance = downstreamElectron.init({
3838
appDir: appDir,
@@ -47,6 +47,8 @@ function createWindow () {
4747
webPreferences: {
4848
plugins: true,
4949
nodeIntegration: true,
50+
// NOTE: is disabled by default since Electron 9
51+
enableRemoteModule: true,
5052
// NOTE: !WARNING! use with caution it allows app to download content
5153
// from any URL
5254
webSecurity: false

0 commit comments

Comments
 (0)