Skip to content
Merged

0.5.0 #134

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [8.x, 10.x, 12.x, 14.x]
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v1
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 0.5.0
* Added Node.js v14 LTS Support
* Added Electron 9 support
* Updated dependencies
* Removed UglifyJs and use TerserJs as a default minimizer
* Moved from `master` branch to `main` branch
* Fixed manifest saving issue (only `undefined` string was stored)
* Dropped Node.js v8 support

# 0.4.0
* Monitor key session state and detect downloaded stream with persistent license
* Node.js v10 LTS Support
Expand Down
32 changes: 16 additions & 16 deletions api/be-methods/downloads/remove-all-unfinished.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ module.exports = function (api, onSuccess, onFailure) {
}
}
Promise.all(promises)
.then(function () {
let promises = [];
for (let i = 0, j = manifestIds.length; i < j; i++) {
promises.push(api.offlineController.removePromise(manifestIds[i]));
}
Promise.all(promises)
.then(function () {
api.subscribersController.unsubscribe(manifestIds);
api.manifestController.removeFromCache(manifestIds);
onSuccess(manifestIds);
}, function (err) {
onFailure(translation.getError(translation.e.downloads.REMOVING_ALL_UNFINISHED_FAILED), err);
});
}, function (err) {
onFailure(translation.getError(translation.e.downloads.REMOVING_ALL_UNFINISHED_FAILED), err);
});
.then(function () {
let promises = [];
for (let i = 0, j = manifestIds.length; i < j; i++) {
promises.push(api.offlineController.removePromise(manifestIds[i]));
}
Promise.all(promises)
.then(function () {
api.subscribersController.unsubscribe(manifestIds);
api.manifestController.removeFromCache(manifestIds);
onSuccess(manifestIds);
}, function (err) {
onFailure(translation.getError(translation.e.downloads.REMOVING_ALL_UNFINISHED_FAILED), err);
});
}, function (err) {
onFailure(translation.getError(translation.e.downloads.REMOVING_ALL_UNFINISHED_FAILED), err);
});
}
});
};
1 change: 1 addition & 0 deletions api/controllers/downloads-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ DownloadsController.prototype.start = function (manifestId, representations, dow
const self = this;
this.downloadStats.start();
const manifest = this._manifestController.getManifestById(manifestId);

if (!manifest) {
onFailure(translation.getError(translation.e.manifests.NOT_FOUND, manifestId));
return;
Expand Down
26 changes: 13 additions & 13 deletions api/controllers/offline-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ function OfflineController (manifestController) {
OfflineController.prototype.getManifestsList = function (callback) {
dirList(appSettings.getSettings().settingsFolder, true, false)
.then(function (settingsFolderList) {
let manifestList = [];
for (let i = 0, j = settingsFolderList.length; i < j; i++) {
manifestList.push(settingsFolderList[i]);
}
callback(null, manifestList);
}, function (err) {
callback(err)
});
let manifestList = [];
for (let i = 0, j = settingsFolderList.length; i < j; i++) {
manifestList.push(settingsFolderList[i]);
}
callback(null, manifestList);
}, function (err) {
callback(err);
});
};

/**
Expand All @@ -60,8 +60,8 @@ OfflineController.prototype.getManifestsListWithInfo = function (callback, full)
}
}
callback(null, newResults);
}, function (err) {
callback(err);
}, function (promisesError) {
callback(promisesError);
});
}
});
Expand Down Expand Up @@ -218,7 +218,7 @@ OfflineController.prototype.getManifestDataFile = function (manifestId, callback
*/
OfflineController.prototype.remove = function (manifestId, onSuccess, onFailure) {
const settingsFolder = appSettings.getSettings().settingsFolder + manifestId;
this.getManifestDataFile( manifestId, function (info) {
this.getManifestDataFile(manifestId, function (info) {
if (!info) {
// no manifest data found for manifest, the download has not been started => just remove settings
rmdir(settingsFolder, function (err) {
Expand All @@ -232,7 +232,7 @@ OfflineController.prototype.remove = function (manifestId, onSuccess, onFailure)
let folder = info.folder;
if (!folder) {
// use default download folder path
folder = path.resolve(appSettings.getSettings().downloadsFolderPath);
folder = path.resolve(appSettings.getSettings().downloadsFolderPath);
}
const downloadsFolder = folder + '/' + manifestId;
rmdir(downloadsFolder, function (err) {
Expand Down Expand Up @@ -311,7 +311,7 @@ OfflineController.prototype.restoreLocalManifest = function (manifestId, onSucce
representations.audio = info.manifest.audio;
representations.text = info.manifest.text;
self._manifestController.saveManifestWithChosenRepresentations(manifestId, representations)
.then(onSuccess, onFailure);
.then(onSuccess, onFailure);
});
};

Expand Down
12 changes: 10 additions & 2 deletions api/downstream-electron-be.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ const Server = require('./server/server.js');

let DownstreamElectronBE;

function deserialize (serializedJavascript) {
try {
return JSON.parse(serializedJavascript);
} catch (err) {
return {};
}
}

/**
* @constructor
* @namespace DownstreamElectronBE
Expand Down Expand Up @@ -182,7 +190,7 @@ DownstreamElectronBE.prototype._getMethod = function (methodName) {
*/
DownstreamElectronBE.prototype._onApiRequest = function (evt, data, target) {
const promiseId = data.promiseId;
const argsObj = data.args || {};
const argsObj = deserialize(data.args) || {};
const method = data.method;
const windowId = data.windowId;
target = windowId;
Expand Down Expand Up @@ -224,7 +232,7 @@ DownstreamElectronBE.prototype._serveOfflineContent = function () {
const maxOfflineContentPortRange = appSettings.getSettings().maxOfflineContentPortRange;

this.server = new Server(this.offlineController, this.downloadsController, maxOfflineContentPortRange, this._offlineContentPort);
this.server.serveOfflineContent( function (offlinePort) {
this.server.serveOfflineContent(function (offlinePort) {
self._offlineContentPort = offlinePort;
})

Expand Down
20 changes: 12 additions & 8 deletions api/downstream-electron-fe.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const translation = require("./translation/index");

let downstreamElectronFE;

function serialize (obj) {
return JSON.stringify(obj);
}

function getWidevinePSSH (info) {
const manifestProtections = info.manifestInfo.protections;
let videoRepresentation = manifestProtections.video[0] || {};
Expand Down Expand Up @@ -138,12 +142,12 @@ DownstreamElectronFE.prototype.downloads.createPersistent = function (args, reso
scope.downloads.savePersistent(manifestId, persistentSessionId).then(function () {
if (existingPersistentSessionId) {
scope._persistent.removePersistentSession(existingPersistentSessionId)
.then(function () {
resolve(persistentSessionId);
})
.catch(function () {
resolve(persistentSessionId);
});
.then(function () {
resolve(persistentSessionId);
})
.catch(function () {
resolve(persistentSessionId);
});
} else {
resolve(persistentSessionId);
}
Expand Down Expand Up @@ -247,7 +251,7 @@ DownstreamElectronFE.prototype._apiCall = function (method, args, originalMethod
request.promiseId = promiseId;
request.method = method;
request.windowId = this._windowId;
request.args = args;
request.args = serialize(args);
this._send(request);
return promise;
};
Expand Down Expand Up @@ -388,7 +392,7 @@ DownstreamElectronFE.prototype._removeSubscribers = function () {
}
}
request.method = 'removeSubscribers';
request.args = [subscribersId];
request.args = serialize([subscribersId]);

this._send(request);
};
Expand Down
4 changes: 2 additions & 2 deletions api/util/dir-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ function dirList (dir, includeFolders, includeFiles) {
resolve(results.filter(function (folderName) {
return typeof folderName !== "undefined"
}));
}, function (err) {
reject(err);
}, function (promiseError) {
reject(promiseError);
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion api/util/save-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require("fs");
const path = require("path");

function saveFile (filePath, fileName, value, callback) {
mkdirp(filePath).then(function (value) {
mkdirp(filePath).then(function () {
const fileUrl = path.resolve(filePath + "/" + fileName);
fs.writeFile(fileUrl, value, "utf-8", callback);
}, function (error) {
Expand Down
6 changes: 4 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ const path = require('path');
// default value of allowRendererProcessReuse false is deprecated
app.allowRendererProcessReuse = true;

function createWindow () {
function createWindow() {
// eslint-disable-next-line no-process-env
let appDir = path.dirname(process.mainModule.filename) + '/';
// head request parameter test
let useHeadRequest = true;

// let useHeadRequest = false;
downstreamInstance = downstreamElectron.init({
appDir: appDir,
Expand All @@ -47,6 +47,8 @@ function createWindow () {
webPreferences: {
plugins: true,
nodeIntegration: true,
// NOTE: is disabled by default since Electron 9
enableRemoteModule: true,
// NOTE: !WARNING! use with caution it allows app to download content
// from any URL
webSecurity: false
Expand Down
17 changes: 2 additions & 15 deletions downstream-electron-be.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions downstream-electron-be.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*!
* downstream-electron,0.5.0,2022-09-07 11:37:00.804,castlabs GmbH
*
* Copyright (C) 2017 Castlabs GmbH.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Loading