mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-04-21 16:31:55 +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) {
|
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;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.cfg.bin.mp4decrypt && !this.cfg.bin.shaka) {
|
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;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1460,12 +1460,12 @@ export default class Crunchy implements ServiceClass {
|
||||||
const pbStreams = pbData.data[0];
|
const pbStreams = pbData.data[0];
|
||||||
|
|
||||||
if (!canDecrypt) {
|
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;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.cfg.bin.mp4decrypt && !this.cfg.bin.shaka) {
|
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;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -657,12 +657,12 @@ export default class Hidive implements ServiceClass {
|
||||||
const chosenFontSize = options.originalFontSize ? undefined : options.fontSize;
|
const chosenFontSize = options.originalFontSize ? undefined : options.fontSize;
|
||||||
let encryptionKeys: KeyContainer[] = [];
|
let encryptionKeys: KeyContainer[] = [];
|
||||||
if (!canDecrypt) {
|
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;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.cfg.bin.mp4decrypt && !this.cfg.bin.shaka) {
|
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;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,38 +19,49 @@ export let canDecrypt: boolean;
|
||||||
try {
|
try {
|
||||||
const files_prd = fs.readdirSync(path.join(workingDir, 'playready'));
|
const files_prd = fs.readdirSync(path.join(workingDir, 'playready'));
|
||||||
const prd_file_found = files_prd.find((f) => f.includes('.prd'));
|
const prd_file_found = files_prd.find((f) => f.includes('.prd'));
|
||||||
if (prd_file_found) {
|
try {
|
||||||
const file_prd = path.join(workingDir, 'playready', prd_file_found);
|
if (prd_file_found) {
|
||||||
const stats = fs.statSync(file_prd);
|
const file_prd = path.join(workingDir, 'playready', prd_file_found);
|
||||||
if (stats.size < 1024 * 8 && stats.isFile()) {
|
const stats = fs.statSync(file_prd);
|
||||||
const fileContents = fs.readFileSync(file_prd, {
|
if (stats.size < 1024 * 8 && stats.isFile()) {
|
||||||
encoding: 'utf8',
|
const fileContents = fs.readFileSync(file_prd, {
|
||||||
});
|
encoding: 'utf8',
|
||||||
if (fileContents.includes('CERT')) {
|
});
|
||||||
prd = fs.readFileSync(file_prd);
|
if (fileContents.includes('CERT')) {
|
||||||
const device = Device.loads(prd);
|
prd = fs.readFileSync(file_prd);
|
||||||
prd_cdm = Cdm.fromDevice(device);
|
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'));
|
const files_wvd = fs.readdirSync(path.join(workingDir, 'widevine'));
|
||||||
files_wvd.forEach(function (file) {
|
try {
|
||||||
file = path.join(workingDir, 'widevine', file);
|
files_wvd.forEach(function (file) {
|
||||||
const stats = fs.statSync(file);
|
file = path.join(workingDir, 'widevine', file);
|
||||||
if (stats.size < 1024 * 8 && stats.isFile()) {
|
const stats = fs.statSync(file);
|
||||||
const fileContents = fs.readFileSync(file, { encoding: 'utf8' });
|
if (stats.size < 1024 * 8 && stats.isFile()) {
|
||||||
if (
|
const fileContents = fs.readFileSync(file, { encoding: 'utf8' });
|
||||||
fileContents.includes('-BEGIN PRIVATE KEY-') ||
|
if (
|
||||||
fileContents.includes('-BEGIN RSA PRIVATE KEY-')
|
fileContents.includes('-BEGIN PRIVATE KEY-') ||
|
||||||
) {
|
fileContents.includes('-BEGIN RSA PRIVATE KEY-')
|
||||||
privateKey = fs.readFileSync(file);
|
) {
|
||||||
|
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) {
|
if (privateKey.length !== 0 && identifierBlob.length !== 0) {
|
||||||
cdm = 'widevine';
|
cdm = 'widevine';
|
||||||
|
|
@ -58,14 +69,15 @@ try {
|
||||||
} else if (prd.length !== 0) {
|
} else if (prd.length !== 0) {
|
||||||
cdm = 'playready';
|
cdm = 'playready';
|
||||||
canDecrypt = true;
|
canDecrypt = true;
|
||||||
} else if (privateKey.length == 0) {
|
} else if (privateKey.length === 0 && identifierBlob.length !== 0) {
|
||||||
console.warn('Private key missing');
|
console.warn('Private key missing');
|
||||||
canDecrypt = false;
|
canDecrypt = false;
|
||||||
} else if (identifierBlob.length == 0) {
|
} else if (identifierBlob.length === 0 && privateKey.length !== 0) {
|
||||||
console.warn('Identifier blob missing');
|
console.warn('Identifier blob missing');
|
||||||
canDecrypt = false;
|
canDecrypt = false;
|
||||||
} else if (prd.length == 0) {
|
} else if (prd.length == 0) {
|
||||||
console.warn('PRD is missing');
|
canDecrypt = false;
|
||||||
|
} else {
|
||||||
canDecrypt = false;
|
canDecrypt = false;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue