diff --git a/ao.ts b/ao.ts index 40465cb..ff2851c 100644 --- a/ao.ts +++ b/ao.ts @@ -476,7 +476,13 @@ export default class AnimeOnegai implements ServiceClass { })); if (!canDecrypt) { - console.warn('Decryption not enabled!'); + console.warn('No Widevine or PlayReady CDM detected. Please ensure a supported 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.'); + return undefined; } const lang = langsData.languages.find(a=>a.ao_locale == media.lang) as langsData.LanguageItem; diff --git a/crunchy.ts b/crunchy.ts index 774f8bb..bde83c8 100644 --- a/crunchy.ts +++ b/crunchy.ts @@ -1460,14 +1460,19 @@ export default class Crunchy implements ServiceClass { const pbStreams = pbData.data[0]; if (!canDecrypt) { - console.warn('Decryption not enabled!'); + console.warn('No Widevine or PlayReady CDM detected. Please ensure a supported 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.'); + return undefined; } for (const s of Object.keys(pbStreams)) { if ( (s.match(/hls/) || s.match(/dash/)) && !(s.match(/hls/) && s.match(/drm/)) - && !((!canDecrypt || !this.cfg.bin.mp4decrypt) && s.match(/drm/)) && !s.match(/trailer/) ) { const pb = Object.values(pbStreams[s]).map(v => { diff --git a/hidive.ts b/hidive.ts index c5642aa..b883a3a 100644 --- a/hidive.ts +++ b/hidive.ts @@ -656,7 +656,15 @@ export default class Hidive implements ServiceClass { const subsMargin = 0; const chosenFontSize = options.originalFontSize ? undefined : options.fontSize; let encryptionKeys: KeyContainer[] = []; - if (!canDecrypt) console.warn('Decryption not enabled!'); + if (!canDecrypt) { + console.warn('No Widevine or PlayReady CDM detected. Please ensure a supported 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.'); + return undefined; + } if (!this.cfg.bin.ffmpeg) this.cfg.bin = await yamlCfg.loadBinCfg(); @@ -823,7 +831,7 @@ export default class Hidive implements ServiceClass { console.error('Failed to get encryption keys'); return undefined; } - if (this.cfg.bin.mp4decrypt) { + if (this.cfg.bin.mp4decrypt || this.cfg.bin.shaka) { let commandBase = `--show-progress --key ${encryptionKeys[cdm === 'playready' ? 0 : 1].kid}:${encryptionKeys[cdm === 'playready' ? 0 : 1].key} `; let commandVideo = commandBase+`"${tempTsFile}.video.enc.m4s" "${tempTsFile}.video.m4s"`; @@ -910,12 +918,17 @@ export default class Hidive implements ServiceClass { console.error('Failed to get encryption keys'); return undefined; } - if (this.cfg.bin.mp4decrypt) { - const commandBase = `--show-progress --key ${encryptionKeys[cdm === 'playready' ? 0 : 1].kid}:${encryptionKeys[cdm === 'playready' ? 0 : 1].key} `; - const commandAudio = commandBase+`"${tempTsFile}.audio.enc.m4s" "${tempTsFile}.audio.m4s"`; + if (this.cfg.bin.mp4decrypt || this.cfg.bin.shaka) { + let commandBase = `--show-progress --key ${encryptionKeys[cdm === 'playready' ? 0 : 1].kid}:${encryptionKeys[cdm === 'playready' ? 0 : 1].key} `; + let commandAudio = commandBase+`"${tempTsFile}.audio.enc.m4s" "${tempTsFile}.audio.m4s"`; + + if (this.cfg.bin.shaka) { + commandBase = ` --enable_raw_key_decryption ${encryptionKeys.map(kb => '--keys key_id='+kb.kid+':key='+kb.key).join(' ')}`; + commandAudio = `input="${tempTsFile}.audio.enc.m4s",stream=audio,output="${tempTsFile}.audio.m4s"`+commandBase; + } console.info('Started decrypting audio'); - const decryptAudio = exec('mp4decrypt', `"${this.cfg.bin.mp4decrypt}"`, commandAudio); + const decryptAudio = exec(this.cfg.bin.shaka ? 'shaka-packager' : 'mp4decrypt', this.cfg.bin.shaka ? `"${this.cfg.bin.shaka}"` : `"${this.cfg.bin.mp4decrypt}"`, commandAudio); if (!decryptAudio.isOk) { console.error(decryptAudio.err); console.error(`Decryption failed with exit code ${decryptAudio.err.code}`);