mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-01-11 20:10:20 +00:00
added better cdm error handeling
This commit is contained in:
parent
d0ddf6d134
commit
88df9ffd55
4 changed files with 49 additions and 37 deletions
4
ao.ts
4
ao.ts
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,38 +19,49 @@ 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'));
|
||||
if (prd_file_found) {
|
||||
const file_prd = path.join(workingDir, 'playready', prd_file_found);
|
||||
const stats = fs.statSync(file_prd);
|
||||
if (stats.size < 1024 * 8 && stats.isFile()) {
|
||||
const fileContents = fs.readFileSync(file_prd, {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
if (fileContents.includes('CERT')) {
|
||||
prd = fs.readFileSync(file_prd);
|
||||
const device = Device.loads(prd);
|
||||
prd_cdm = Cdm.fromDevice(device);
|
||||
try {
|
||||
if (prd_file_found) {
|
||||
const file_prd = path.join(workingDir, 'playready', prd_file_found);
|
||||
const stats = fs.statSync(file_prd);
|
||||
if (stats.size < 1024 * 8 && stats.isFile()) {
|
||||
const fileContents = fs.readFileSync(file_prd, {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
if (fileContents.includes('CERT')) {
|
||||
prd = fs.readFileSync(file_prd);
|
||||
const device = Device.loads(prd);
|
||||
prd_cdm = Cdm.fromDevice(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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'));
|
||||
files_wvd.forEach(function (file) {
|
||||
file = path.join(workingDir, 'widevine', file);
|
||||
const stats = fs.statSync(file);
|
||||
if (stats.size < 1024 * 8 && stats.isFile()) {
|
||||
const fileContents = fs.readFileSync(file, { encoding: 'utf8' });
|
||||
if (
|
||||
fileContents.includes('-BEGIN PRIVATE KEY-') ||
|
||||
fileContents.includes('-BEGIN RSA PRIVATE KEY-')
|
||||
) {
|
||||
privateKey = fs.readFileSync(file);
|
||||
try {
|
||||
files_wvd.forEach(function (file) {
|
||||
file = path.join(workingDir, 'widevine', file);
|
||||
const stats = fs.statSync(file);
|
||||
if (stats.size < 1024 * 8 && stats.isFile()) {
|
||||
const fileContents = fs.readFileSync(file, { encoding: 'utf8' });
|
||||
if (
|
||||
fileContents.includes('-BEGIN PRIVATE KEY-') ||
|
||||
fileContents.includes('-BEGIN RSA PRIVATE KEY-')
|
||||
) {
|
||||
privateKey = fs.readFileSync(file);
|
||||
}
|
||||
if (fileContents.includes('widevine_cdm_version')) {
|
||||
identifierBlob = fs.readFileSync(file);
|
||||
}
|
||||
}
|
||||
if (fileContents.includes('widevine_cdm_version')) {
|
||||
identifierBlob = fs.readFileSync(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
} 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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue