From 99ca2a1a97da327304a14c7554370407ca9d1aaf Mon Sep 17 00:00:00 2001 From: Wessel Kroos Date: Sat, 9 Apr 2022 07:37:43 +0200 Subject: [PATCH] Widevine DRM signing support via the python package Castlabs EVS --- .gitignore | 3 ++- Readme.md | 6 ++++++ after-sign.js | 30 ++++++++++++++++++++++++++++++ main.js | 3 ++- package.json | 3 ++- 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 after-sign.js diff --git a/.gitignore b/.gitignore index b7ca1d9..3307cb1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /dist /node_modules -/windowBounds.* \ No newline at end of file +/windowBounds.* +*.config \ No newline at end of file diff --git a/Readme.md b/Readme.md index 85149f8..1797f78 100644 --- a/Readme.md +++ b/Readme.md @@ -14,6 +14,12 @@ __This app is unofficial and is not associated in any way with the Formula 1 com ## Installation 1. Install the LTS version of Node: [Node (LTS)](https://nodejs.org/) 2. Run in a cmd window: `npm install` +#### Optional steps for DRM support (Required to play streams with Widevine DRM) +3. Install python 3: [Python 3](https://www.python.org/downloads/) +4. Install the castlabs-evs package for Python: `python -m pip install --upgrade castlabs-evs` +5. Sign up for an EVS account: `python -m castlabs_evs.account signup` +6. For DRM support while develping, sign the electron.exe file: `python -m castlabs_evs.vmp sign-pkg node_modules/electron/dist` +7. For more info about EVS: https://github.com/castlabs/electron-releases/wiki/EVS ## Start the app 1. run in a cmd window: `npm start` \ No newline at end of file diff --git a/after-sign.js b/after-sign.js new file mode 100644 index 0000000..9b2523d --- /dev/null +++ b/after-sign.js @@ -0,0 +1,30 @@ +exports.default = async function(context) { + + // If we are not packaging for windows we don't sign here, just return + if (context.packager.platform.name !== 'windows') { + return; + } + + // Make sure we don't leave an outdated electron.exe.sig laying about + if (context.packager.appInfo.productFilename !== 'electron') { + var fs = require("fs"); + var path = context.appOutDir + '/electron.exe.sig' + if (fs.existsSync(path)) { + fs.unlinkSync(path) + } + } + + // Sign the application package + var spawnSync = require("child_process").spawnSync; + var vmp = spawnSync('python', [ + '-m', 'castlabs_evs.vmp', 'sign-pkg', 'dist/win-unpacked' + ], + { + stdio: 'inherit' + }); + + if (vmp.status != 0) { + throw new Error('vmp-resign.py failed with code: ' + vmp.status); + } + +} \ No newline at end of file diff --git a/main.js b/main.js index 3a12801..8504517 100644 --- a/main.js +++ b/main.js @@ -113,7 +113,8 @@ ipcMain.handle('video-ipc', (event, videoUrl, referrer) => { webPreferences: { contextIsolation: false, nodeIntegration: true, - webviewTag: true + webviewTag: true, + plugins: true } } diff --git a/package.json b/package.json index b9ecd1c..20b3293 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "productName": "Race TV Multiplayer", "electronDownload": { "mirror": "https://github.com/castlabs/electron-releases/releases/download/v" - } + }, + "afterSign": "./after-sign.js" } }