hotfix shaka

This commit is contained in:
stratumadev 2025-01-29 13:18:08 +01:00
parent a2a54511ad
commit f9a0a12abc
3 changed files with 33 additions and 9 deletions

8
ao.ts
View file

@ -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;

View file

@ -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 => {

View file

@ -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}`);