Merge pull request #812 from stratumadev/master
Some checks failed
auto-documentation / documentation (push) Has been cancelled
build and push docker image / build-node (push) Has been cancelled
Style and build test / eslint (push) Has been cancelled
Style and build test / test (push) Has been cancelled

Added better cdm error handeling
This commit is contained in:
Stratum 2025-01-30 16:12:36 +01:00 committed by GitHub
commit 267480c1ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 49 additions and 37 deletions

4
ao.ts
View file

@ -476,12 +476,12 @@ export default class AnimeOnegai implements ServiceClass {
}));
if (!canDecrypt) {
console.warn('No Widevine or PlayReady CDM detected. Please ensure a supported CDM is installed.');
console.error('No valid Widevine or PlayReady CDM detected. Please ensure a supported and functional CDM is installed.');
return undefined;
}
if (!this.cfg.bin.mp4decrypt && !this.cfg.bin.shaka) {
console.warn('Missing dependencies: Neither Shaka nor MP4Decrypt found. Please ensure at least one of them is installed.');
console.error('Neither Shaka nor MP4Decrypt found. Please ensure at least one of them is installed.');
return undefined;
}

View file

@ -1460,12 +1460,12 @@ export default class Crunchy implements ServiceClass {
const pbStreams = pbData.data[0];
if (!canDecrypt) {
console.warn('No Widevine or PlayReady CDM detected. Please ensure a supported CDM is installed.');
console.error('No valid Widevine or PlayReady CDM detected. Please ensure a supported and functional CDM is installed.');
return undefined;
}
if (!this.cfg.bin.mp4decrypt && !this.cfg.bin.shaka) {
console.warn('Missing dependencies: Neither Shaka nor MP4Decrypt found. Please ensure at least one of them is installed.');
console.error('Neither Shaka nor MP4Decrypt found. Please ensure at least one of them is installed.');
return undefined;
}

View file

@ -657,12 +657,12 @@ export default class Hidive implements ServiceClass {
const chosenFontSize = options.originalFontSize ? undefined : options.fontSize;
let encryptionKeys: KeyContainer[] = [];
if (!canDecrypt) {
console.warn('No Widevine or PlayReady CDM detected. Please ensure a supported CDM is installed.');
console.error('No valid Widevine or PlayReady CDM detected. Please ensure a supported and functional CDM is installed.');
return undefined;
}
if (!this.cfg.bin.mp4decrypt && !this.cfg.bin.shaka) {
console.warn('Missing dependencies: Neither Shaka nor MP4Decrypt found. Please ensure at least one of them is installed.');
console.error('Neither Shaka nor MP4Decrypt found. Please ensure at least one of them is installed.');
return undefined;
}

View file

@ -19,6 +19,7 @@ export let canDecrypt: boolean;
try {
const files_prd = fs.readdirSync(path.join(workingDir, 'playready'));
const prd_file_found = files_prd.find((f) => f.includes('.prd'));
try {
if (prd_file_found) {
const file_prd = path.join(workingDir, 'playready', prd_file_found);
const stats = fs.statSync(file_prd);
@ -33,8 +34,13 @@ try {
}
}
}
} catch (e) {
console.error('Error loading Playready CDM, ensure the CDM is provisioned as a V3 Device and not malformed. For more informations read the readme.');
prd = Buffer.from([]);
}
const files_wvd = fs.readdirSync(path.join(workingDir, 'widevine'));
try {
files_wvd.forEach(function (file) {
file = path.join(workingDir, 'widevine', file);
const stats = fs.statSync(file);
@ -51,6 +57,11 @@ try {
}
}
});
} catch (e) {
console.error('Error loading Widevine CDM, malformed client blob or private key.');
privateKey = Buffer.from([]);
identifierBlob = Buffer.from([]);
}
if (privateKey.length !== 0 && identifierBlob.length !== 0) {
cdm = 'widevine';
@ -58,14 +69,15 @@ try {
} else if (prd.length !== 0) {
cdm = 'playready';
canDecrypt = true;
} else if (privateKey.length == 0) {
} else if (privateKey.length === 0 && identifierBlob.length !== 0) {
console.warn('Private key missing');
canDecrypt = false;
} else if (identifierBlob.length == 0) {
} else if (identifierBlob.length === 0 && privateKey.length !== 0) {
console.warn('Identifier blob missing');
canDecrypt = false;
} else if (prd.length == 0) {
console.warn('PRD is missing');
canDecrypt = false;
} else {
canDecrypt = false;
}
} catch (e) {