added hidive playready support

This commit is contained in:
stratumadev 2024-12-19 10:35:04 +01:00
parent 70bddc8de2
commit ef06b5885f
2 changed files with 15 additions and 9 deletions

View file

@ -35,7 +35,7 @@ import { Episode, NewHidiveEpisodeExtra, NewHidiveSeason, NewHidiveSeriesExtra }
import { NewHidiveEpisode } from './@types/newHidiveEpisode';
import { NewHidivePlayback, Subtitle } from './@types/newHidivePlayback';
import { MPDParsed, parse } from './modules/module.transform-mpd';
import { canDecrypt, getKeysWVD, cdm } from './modules/cdm';
import { canDecrypt, getKeysWVD, cdm, getKeysPRD } from './modules/cdm';
import { exec } from './modules/sei-helper-fixes';
import { KeyContainer } from './modules/license';
@ -763,13 +763,19 @@ export default class Hidive implements ServiceClass {
console.info(`Selected (Available) Audio Languages: ${chosenAudios.map(a => a.language.name).join(', ')}`);
console.info('Stream URL:', chosenVideoSegments.segments[0].map.uri.split('/init.mp4')[0]);
// Only Widevine supported and tested, Hidive Playready support needs to be checked first
if (chosenAudios[0].pssh_wvd || chosenVideoSegments.pssh_wvd) {
if (chosenAudios[0].pssh_wvd && cdm === 'widevine' || chosenVideoSegments.pssh_wvd && cdm === 'widevine') {
encryptionKeys = await getKeysWVD(chosenVideoSegments.pssh_wvd, 'https://shield-drm.imggaming.com/api/v2/license', {
'Authorization': `Bearer ${selectedEpisode.jwtToken}`,
'X-Drm-Info': 'eyJzeXN0ZW0iOiJjb20ud2lkZXZpbmUuYWxwaGEifQ==',
});
}
if (chosenAudios[0].pssh_prd && cdm === 'playready' || chosenVideoSegments.pssh_prd && cdm === 'playready') {
encryptionKeys = await getKeysPRD(chosenVideoSegments.pssh_wvd, 'https://shield-drm.imggaming.com/api/v2/license', {
'Authorization': `Bearer ${selectedEpisode.jwtToken}`,
'X-Drm-Info': 'eyJzeXN0ZW0iOiJjb20ubWljcm9zb2Z0LnBsYXlyZWFkeSJ9',
});
}
if (!options.novids) {
//Download Video
@ -811,14 +817,14 @@ export default class Hidive implements ServiceClass {
console.error(`DL Stats: ${JSON.stringify(videoDownload.parts)}\n`);
dlFailed = true;
} else {
if (chosenVideoSegments.pssh_wvd) {
if (chosenVideoSegments.pssh_wvd || chosenVideoSegments.pssh_prd) {
console.info('Decryption Needed, attempting to decrypt');
if (encryptionKeys.length == 0) {
console.error('Failed to get encryption keys');
return undefined;
}
if (this.cfg.bin.mp4decrypt) {
const commandBase = `--show-progress --key ${encryptionKeys[1].kid}:${encryptionKeys[1].key} `;
const commandBase = `--show-progress --key ${encryptionKeys[cdm === 'playready' ? 0 : 1].kid}:${encryptionKeys[cdm === 'playready' ? 0 : 1].key} `;
const commandVideo = commandBase+`"${tempTsFile}.video.enc.m4s" "${tempTsFile}.video.m4s"`;
console.info('Started decrypting video');
@ -893,14 +899,14 @@ export default class Hidive implements ServiceClass {
console.error(`DL Stats: ${JSON.stringify(audioDownload.parts)}\n`);
dlFailed = true;
}
if (chosenAudioSegments.pssh_wvd) {
if (chosenAudioSegments.pssh_wvd || chosenAudioSegments.pssh_prd) {
console.info('Decryption Needed, attempting to decrypt');
if (encryptionKeys.length == 0) {
console.error('Failed to get encryption keys');
return undefined;
}
if (this.cfg.bin.mp4decrypt) {
const commandBase = `--show-progress --key ${encryptionKeys[1].kid}:${encryptionKeys[1].key} `;
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"`;
console.info('Started decrypting audio');

View file

@ -152,7 +152,7 @@ export async function getKeysPRD(
pssh: string | undefined,
licenseServer: string,
authData: Record<string, string>
): Promise<KeyContainer[] | undefined> {
): Promise<KeyContainer[]> {
if (!pssh || !canDecrypt || !prd_cdm) return [];
const pssh_parsed = new PSSH(pssh);
@ -218,7 +218,7 @@ export async function getKeysPRD(
};
});
} catch {
return undefined;
return [];
}
} else {
console.info(