Support using a Widevine-enabled Electron for DRM playback (fix #435) (PR #1073)

This commit is contained in:
erythros 2020-11-21 09:39:07 -05:00 committed by GitHub
parent 7531c3136e
commit bbd51ad988
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 1 deletions

View File

@ -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]
```

View File

@ -118,6 +118,10 @@ if (require.main === module) {
'-e, --electron-version <value>',
"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',

View File

@ -39,7 +39,7 @@ export function getTempDir(prefix: string, mode?: number): string {
export async function copyFileOrDir(
sourceFileOrDir: string,
dest: string,
): Promise<any> {
): Promise<void> {
return new Promise((resolve, reject) => {
ncp(sourceFileOrDir, dest, (error: any) => {
if (error) {

View File

@ -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<AppOptions> {
}
}
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;
}