Only show DRM streams if they can be decrypted

This commit is contained in:
AnimeDL 2024-01-26 10:38:25 -08:00
parent fe997ecb32
commit f204b068ea
2 changed files with 17 additions and 6 deletions

View file

@ -18,7 +18,7 @@ import * as langsData from './modules/module.langsData';
import * as yamlCfg from './modules/module.cfg-loader';
import * as yargs from './modules/module.app-args';
import Merger, { Font, MergerInput, SubtitleInput } from './modules/module.merger';
import getKeys from './modules/cr_widevine';
import getKeys, { canDecrypt } from './modules/cr_widevine';
// args
@ -1260,8 +1260,12 @@ export default class Crunchy implements ServiceClass {
const pbStreams = pbData.data[0];
for(const s of Object.keys(pbStreams)){
//if(s.match(/hls/) && !s.match(/drm/) && !s.match(/trailer/)) {
if((s.match(/hls/) || s.match(/dash/)) && !(s.match(/hls/) && s.match(/drm/)) && !s.match(/trailer/)) {
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 => {
v.hardsub_lang = v.hardsub_locale
? langsData.fixAndFindCrLC(v.hardsub_locale).locale

View file

@ -6,11 +6,18 @@ import { workingDir } from './module.cfg-loader';
import path from 'path';
//read cdm files located in the same directory
const privateKey = fs.readFileSync(path.join(workingDir, 'widevine', 'device_private_key'));
const identifierBlob = fs.readFileSync(path.join(workingDir, 'widevine', 'device_client_id_blob'));
let privateKey: Buffer, identifierBlob: Buffer;
export let canDecrypt: boolean;
try {
privateKey = fs.readFileSync(path.join(workingDir, 'widevine', 'device_private_key'));
identifierBlob = fs.readFileSync(path.join(workingDir, 'widevine', 'device_client_id_blob'));
canDecrypt = true;
} catch (e) {
canDecrypt = false;
}
export default async function getKeys(pssh: string | undefined, licenseServer: string, authData: Record<string, string>): Promise<KeyContainer[]> {
if (!pssh) return [];
if (!pssh || !canDecrypt) return [];
//pssh found in the mpd manifest
const psshBuffer = Buffer.from(
pssh,