diff --git a/docs/api.md b/docs/api.md index 1b94f7e..6ac7b50 100644 --- a/docs/api.md +++ b/docs/api.md @@ -16,6 +16,7 @@ - [[app-version]](#app-version) - [[build-version]](#build-version) - [[electron-version]](#electron-version) + - [[widevine]](#widevine) - [[no-overwrite]](#no-overwrite) - [[conceal]](#conceal) - [[icon]](#icon) @@ -171,6 +172,14 @@ The build version of the application. Maps to the `FileVersion` metadata propert Electron version without the `v`, see https://github.com/atom/electron/releases. +#### [widevine] + +``` +--widevine +``` + +Use a Widevine-enabled version of Electron for DRM playback, see https://github.com/castlabs/electron-releases. + #### [no-overwrite] ``` diff --git a/src/cli.ts b/src/cli.ts index 83f2f35..cbd5137 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -118,6 +118,10 @@ if (require.main === module) { '-e, --electron-version ', "electron version to package, without the 'v', see https://github.com/electron/electron/releases", ) + .option( + '--widevine', + "use a Widevine-enabled version of Electron for DRM playback (use at your own risk, it's unofficial, provided by CastLabs)", + ) .option( '--no-overwrite', 'do not override output directory if it already exists; defaults to false', diff --git a/src/helpers/helpers.ts b/src/helpers/helpers.ts index 3f7df8a..cc93d80 100644 --- a/src/helpers/helpers.ts +++ b/src/helpers/helpers.ts @@ -39,7 +39,7 @@ export function getTempDir(prefix: string, mode?: number): string { export async function copyFileOrDir( sourceFileOrDir: string, dest: string, -): Promise { +): Promise { return new Promise((resolve, reject) => { ncp(sourceFileOrDir, dest, (error: any) => { if (error) { diff --git a/src/options/optionsMain.ts b/src/options/optionsMain.ts index d296c52..63a7edd 100644 --- a/src/options/optionsMain.ts +++ b/src/options/optionsMain.ts @@ -1,5 +1,6 @@ import * as fs from 'fs'; +import axios from 'axios'; import * as log from 'loglevel'; // package.json is `require`d to let tsc strip the `src` folder by determining @@ -130,6 +131,26 @@ export async function getOptions(rawOptions: any): Promise { } } + if (rawOptions.widevine) { + const widevineElectronVersion = `${options.packager.electronVersion}-wvvmp`; + try { + await axios.get( + `https://github.com/castlabs/electron-releases/releases/tag/v${widevineElectronVersion}`, + ); + } catch (error) { + throw `\nERROR: castLabs Electron version "${widevineElectronVersion}" does not exist. \nVerify versions at https://github.com/castlabs/electron-releases/releases. \nAborting.`; + } + + options.packager.electronVersion = widevineElectronVersion; + process.env.ELECTRON_MIRROR = + 'https://github.com/castlabs/electron-releases/releases/download/'; + log.warn( + `\nATTENTION: Using the **unofficial** Electron from castLabs`, + "\nIt implements Google's Widevine Content Decryption Module (CDM) for DRM-enabled playback.", + `\nSimply abort & re-run without passing the widevine flag to default to ${DEFAULT_ELECTRON_VERSION}`, + ); + } + if (options.nativefier.flashPluginDir) { options.nativefier.insecure = true; }