mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-03-11 17:45:30 +00:00
[CR] Add crunchy play streams selector
This commit is contained in:
parent
16dbc4f1eb
commit
c294cdc280
6 changed files with 62 additions and 23 deletions
2
@types/crunchyTypes.d.ts
vendored
2
@types/crunchyTypes.d.ts
vendored
|
|
@ -2,10 +2,12 @@ import { HLSCallback } from 'hls-download';
|
|||
import { sxItem } from '../crunchy';
|
||||
import { LanguageItem } from '../modules/module.langsData';
|
||||
import { DownloadInfo } from './messageHandler';
|
||||
import { CrunchyPlayStreams } from './enums';
|
||||
|
||||
export type CrunchyDownloadOptions = {
|
||||
hslang: string,
|
||||
kstream: number,
|
||||
cpstream: keyof typeof CrunchyPlayStreams | 'none',
|
||||
novids?: boolean,
|
||||
noaudio?: boolean,
|
||||
x: number,
|
||||
|
|
|
|||
16
@types/enums.ts
Normal file
16
@types/enums.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
export enum CrunchyPlayStreams {
|
||||
'chrome' = 'web/chrome',
|
||||
'firefox' = 'web/firefox',
|
||||
'safari' = 'web/safari',
|
||||
'edge' = 'web/edge',
|
||||
'fallback' = 'web/fallback',
|
||||
'ps4' = 'console/ps4',
|
||||
'ps5' = 'console/ps5',
|
||||
'switch' = 'console/switch',
|
||||
'samsungtv' = 'tv/samsung',
|
||||
'lgtv' = 'tv/lg',
|
||||
'rokutv' = 'tv/roku',
|
||||
'android' = 'android/phone',
|
||||
'iphone' = 'ios/iphone',
|
||||
'ipad' = 'ios/ipad',
|
||||
}
|
||||
46
crunchy.ts
46
crunchy.ts
|
|
@ -44,6 +44,7 @@ import { CrunchyAndroidObject } from './@types/crunchyAndroidObject';
|
|||
import { CrunchyChapters, CrunchyChapter, CrunchyOldChapter } from './@types/crunchyChapters';
|
||||
import vtt2ass from './modules/module.vtt2ass';
|
||||
import { CrunchyPlayStream } from './@types/crunchyPlayStreams';
|
||||
import { CrunchyPlayStreams } from './@types/enums';
|
||||
|
||||
export type sxItem = {
|
||||
language: langsData.LanguageItem,
|
||||
|
|
@ -1414,27 +1415,30 @@ export default class Crunchy implements ServiceClass {
|
|||
pbData = await playbackReq.res.json() as PlaybackData;
|
||||
}
|
||||
|
||||
let switchStream: CrunchyPlayStream | null = null;
|
||||
const playbackReq = await this.req.getData(`https://cr-play-service.prd.crunchyrollsvc.com/v1/${currentVersion ? currentVersion.guid : currentMediaId}/console/switch/play`, AuthHeaders);
|
||||
if(!playbackReq.ok || !playbackReq.res) {
|
||||
console.error('Non-DRM Request Stream URLs FAILED!');
|
||||
} else {
|
||||
switchStream = await playbackReq.res.json() as CrunchyPlayStream;
|
||||
const derivedPlaystreams = {} as CrunchyStreams;
|
||||
for (const hardsub in switchStream.hardSubs) {
|
||||
const stream = switchStream.hardSubs[hardsub];
|
||||
derivedPlaystreams[hardsub] = {
|
||||
url: stream.url,
|
||||
'hardsub_locale': stream.hlang
|
||||
|
||||
let playStream: CrunchyPlayStream | null = null;
|
||||
if (options.cpstream !== 'none') {
|
||||
const playbackReq = await this.req.getData(`https://cr-play-service.prd.crunchyrollsvc.com/v1/${currentVersion ? currentVersion.guid : currentMediaId}/${CrunchyPlayStreams[options.cpstream]}/play`, AuthHeaders);
|
||||
if (!playbackReq.ok || !playbackReq.res) {
|
||||
console.error('Non-DRM Request Stream URLs FAILED!');
|
||||
} else {
|
||||
playStream = await playbackReq.res.json() as CrunchyPlayStream;
|
||||
const derivedPlaystreams = {} as CrunchyStreams;
|
||||
for (const hardsub in playStream.hardSubs) {
|
||||
const stream = playStream.hardSubs[hardsub];
|
||||
derivedPlaystreams[hardsub] = {
|
||||
url: stream.url,
|
||||
'hardsub_locale': stream.hlang
|
||||
};
|
||||
}
|
||||
derivedPlaystreams[''] = {
|
||||
url: playStream.url,
|
||||
hardsub_locale: ''
|
||||
};
|
||||
pbData.data[0][`adaptive_${options.cpstream}_${playStream.url.includes('m3u8') ? 'hls' : 'dash'}_drm`] = {
|
||||
...derivedPlaystreams
|
||||
};
|
||||
}
|
||||
derivedPlaystreams[''] = {
|
||||
url: switchStream.url,
|
||||
hardsub_locale: ''
|
||||
};
|
||||
pbData.data[0]['adaptive_switch_dash'] = {
|
||||
...derivedPlaystreams
|
||||
};
|
||||
}
|
||||
|
||||
variables.push(...([
|
||||
|
|
@ -2131,9 +2135,9 @@ export default class Crunchy implements ServiceClass {
|
|||
console.info('Subtitles downloading skipped!');
|
||||
}
|
||||
|
||||
if (switchStream) {
|
||||
if (playStream) {
|
||||
await this.refreshToken(true, true);
|
||||
await this.req.getData(`https://cr-play-service.prd.crunchyrollsvc.com/v1/token/${currentVersion ? currentVersion.guid : currentMediaId}/${switchStream.token}`, {...{method: 'DELETE'}, ...AuthHeaders});
|
||||
await this.req.getData(`https://cr-play-service.prd.crunchyrollsvc.com/v1/token/${currentVersion ? currentVersion.guid : currentMediaId}/${playStream.token}`, {...{method: 'DELETE'}, ...AuthHeaders});
|
||||
}
|
||||
|
||||
await this.sleep(options.waittime);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { DownloadInfo } from '../@types/messageHandler';
|
|||
import { HLSCallback } from './hls-download';
|
||||
import leven from 'leven';
|
||||
import { console } from './log';
|
||||
import { CrunchyPlayStreams } from '../@types/enums';
|
||||
|
||||
let argvC: {
|
||||
[x: string]: unknown;
|
||||
|
|
@ -42,7 +43,8 @@ let argvC: {
|
|||
extid: string | undefined;
|
||||
q: number;
|
||||
x: number;
|
||||
kstream: number;
|
||||
kstream: number;
|
||||
cpstream: keyof typeof CrunchyPlayStreams | 'none';
|
||||
partsize: number;
|
||||
hslang: string;
|
||||
dlsubs: string[];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { aoSearchLocales, dubLanguageCodes, languages, searchLocales, subtitleLanguagesFilter } from './module.langsData';
|
||||
import { CrunchyPlayStreams } from '../@types/enums';
|
||||
|
||||
const groups = {
|
||||
'auth': 'Authentication:',
|
||||
|
|
@ -283,6 +284,20 @@ const args: TAppArg<boolean|number|string|unknown[]>[] = [
|
|||
type: 'number',
|
||||
usage: '${stream}'
|
||||
},
|
||||
{
|
||||
name: 'cpstream',
|
||||
group: 'dl',
|
||||
alias: 'cps',
|
||||
service: ['crunchy'],
|
||||
type: 'string',
|
||||
describe: 'Select specific crunchy play stream by device, or disable stream with "none"',
|
||||
choices: [...Object.keys(CrunchyPlayStreams), 'none'],
|
||||
default: {
|
||||
default: 'chrome'
|
||||
},
|
||||
docDescribe: true,
|
||||
usage: '${device}'
|
||||
},
|
||||
{
|
||||
name: 'hslang',
|
||||
group: 'dl',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "multi-downloader-nx",
|
||||
"short_name": "aniDL",
|
||||
"version": "5.0.4b1",
|
||||
"version": "5.0.4b2",
|
||||
"description": "Downloader for Crunchyroll, Hidive, AnimeOnegai, and AnimationDigitalNetwork with CLI and GUI",
|
||||
"keywords": [
|
||||
"download",
|
||||
|
|
|
|||
Loading…
Reference in a new issue