[CR] Add Switch Stream
This commit is contained in:
parent
80c7f5ba77
commit
90100a077d
3 changed files with 87 additions and 19 deletions
42
@types/crunchyPlayStreams.d.ts
vendored
Normal file
42
@types/crunchyPlayStreams.d.ts
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
export interface CrunchyPlayStream {
|
||||
assetId: string;
|
||||
audioLocale: string;
|
||||
bifs: string;
|
||||
burnedInLocale: string;
|
||||
captions: { [key: string]: Caption };
|
||||
hardSubs: { [key: string]: HardSub };
|
||||
playbackType: string;
|
||||
session: Session;
|
||||
subtitles: { [key: string]: Subtitle };
|
||||
token: string;
|
||||
url: string;
|
||||
versions: any[];
|
||||
}
|
||||
|
||||
export interface Caption {
|
||||
format: string;
|
||||
language: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export interface HardSub {
|
||||
hlang: string;
|
||||
url: string;
|
||||
quality: string;
|
||||
}
|
||||
|
||||
export interface Session {
|
||||
renewSeconds: number;
|
||||
noNetworkRetryIntervalSeconds: number;
|
||||
noNetworkTimeoutSeconds: number;
|
||||
maximumPauseSeconds: number;
|
||||
endOfVideoUnloadSeconds: number;
|
||||
sessionExpirationSeconds: number;
|
||||
usesStreamLimits: boolean;
|
||||
}
|
||||
|
||||
export interface Subtitle {
|
||||
format: string;
|
||||
language: string;
|
||||
url: string;
|
||||
}
|
||||
36
@types/playbackData.d.ts
vendored
36
@types/playbackData.d.ts
vendored
|
|
@ -6,24 +6,24 @@ export interface PlaybackData {
|
|||
}
|
||||
|
||||
export interface StreamList {
|
||||
download_hls: Streams;
|
||||
drm_adaptive_hls: Streams;
|
||||
multitrack_adaptive_hls_v2: Streams;
|
||||
vo_adaptive_hls: Streams;
|
||||
vo_drm_adaptive_hls: Streams;
|
||||
adaptive_hls: Streams;
|
||||
drm_download_dash: Streams;
|
||||
drm_download_hls: Streams;
|
||||
drm_multitrack_adaptive_hls_v2: Streams;
|
||||
vo_drm_adaptive_dash: Streams;
|
||||
adaptive_dash: Streams;
|
||||
urls: Streams;
|
||||
vo_adaptive_dash: Streams;
|
||||
download_dash: Streams;
|
||||
drm_adaptive_dash: Streams;
|
||||
download_hls: CrunchyStreams;
|
||||
drm_adaptive_hls: CrunchyStreams;
|
||||
multitrack_adaptive_hls_v2: CrunchyStreams;
|
||||
vo_adaptive_hls: CrunchyStreams;
|
||||
vo_drm_adaptive_hls: CrunchyStreams;
|
||||
adaptive_hls: CrunchyStreams;
|
||||
drm_download_dash: CrunchyStreams;
|
||||
drm_download_hls: CrunchyStreams;
|
||||
drm_multitrack_adaptive_hls_v2: CrunchyStreams;
|
||||
vo_drm_adaptive_dash: CrunchyStreams;
|
||||
adaptive_dash: CrunchyStreams;
|
||||
urls: CrunchyStreams;
|
||||
vo_adaptive_dash: CrunchyStreams;
|
||||
download_dash: CrunchyStreams;
|
||||
drm_adaptive_dash: CrunchyStreams;
|
||||
}
|
||||
|
||||
export interface Streams {
|
||||
export interface CrunchyStreams {
|
||||
'': StreamDetails;
|
||||
'en-US'?: StreamDetails;
|
||||
'es-LA'?: StreamDetails;
|
||||
|
|
@ -41,10 +41,12 @@ export interface Streams {
|
|||
'zh-CN'?: StreamDetails;
|
||||
'ko-KR'?: StreamDetails;
|
||||
'ja-JP'?: StreamDetails;
|
||||
[string: string]: StreamDetails;
|
||||
}
|
||||
|
||||
export interface StreamDetails {
|
||||
hardsub_locale: Locale;
|
||||
//hardsub_locale: Locale;
|
||||
hardsub_locale: string;
|
||||
url: string;
|
||||
hardsub_lang?: string;
|
||||
audio_lang?: string;
|
||||
|
|
|
|||
28
crunchy.ts
28
crunchy.ts
|
|
@ -31,7 +31,7 @@ import { CrunchyEpisodeList, CrunchyEpisode } from './@types/crunchyEpisodeList'
|
|||
import { CrunchyDownloadOptions, CrunchyEpMeta, CrunchyMuxOptions, CrunchyMultiDownload, DownloadedMedia, ParseItem, SeriesSearch, SeriesSearchItem } from './@types/crunchyTypes';
|
||||
import { ObjectInfo } from './@types/objectInfo';
|
||||
import parseFileName, { Variable } from './modules/module.filename';
|
||||
import { PlaybackData } from './@types/playbackData';
|
||||
import { CrunchyStreams, PlaybackData } from './@types/playbackData';
|
||||
import { downloaded } from './modules/module.downloadArchive';
|
||||
import parseSelect from './modules/module.parseSelect';
|
||||
import { AvailableFilenameVars, getDefault } from './modules/module.args';
|
||||
|
|
@ -43,6 +43,7 @@ import { parse } from './modules/module.transform-mpd';
|
|||
import { CrunchyAndroidObject } from './@types/crunchyAndroidObject';
|
||||
import { CrunchyChapters, CrunchyChapter, CrunchyOldChapter } from './@types/crunchyChapters';
|
||||
import vtt2ass from './modules/module.vtt2ass';
|
||||
import { CrunchyPlayStream } from './@types/crunchyPlayStreams';
|
||||
|
||||
export type sxItem = {
|
||||
language: langsData.LanguageItem,
|
||||
|
|
@ -1207,6 +1208,7 @@ export default class Crunchy implements ServiceClass {
|
|||
const AuthHeaders = {
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.token.access_token}`,
|
||||
'X-Cr-Disable-Drm': 'true'
|
||||
},
|
||||
useProxy: true
|
||||
};
|
||||
|
|
@ -1395,6 +1397,28 @@ export default class Crunchy implements ServiceClass {
|
|||
pbData = JSON.parse(playbackReq.res.body) as PlaybackData;
|
||||
}
|
||||
|
||||
const playbackReq = await this.req.getData(`https://cr-play-service.prd.crunchyrollsvc.com/v1/${mMeta.mediaId}/console/switch/play`, AuthHeaders);
|
||||
if(!playbackReq.ok || !playbackReq.res){
|
||||
console.error('Non-DRM Request Stream URLs FAILED!');
|
||||
} else {
|
||||
const playStream = JSON.parse(playbackReq.res.body) 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_switch_dash'] = {
|
||||
...derivedPlaystreams
|
||||
};
|
||||
}
|
||||
|
||||
variables.push(...([
|
||||
['title', medias.episodeTitle, true],
|
||||
['episode', isNaN(parseFloat(medias.episodeNumber)) ? medias.episodeNumber : parseFloat(medias.episodeNumber), false],
|
||||
|
|
@ -1520,7 +1544,7 @@ export default class Crunchy implements ServiceClass {
|
|||
let tsFile = undefined;
|
||||
|
||||
if(!dlFailed && curStream !== undefined && !(options.novids && options.noaudio)){
|
||||
const streamPlaylistsReq = await this.req.getData(curStream.url);
|
||||
const streamPlaylistsReq = await this.req.getData(curStream.url, AuthHeaders);
|
||||
if(!streamPlaylistsReq.ok || !streamPlaylistsReq.res){
|
||||
console.error('CAN\'T FETCH VIDEO PLAYLISTS!');
|
||||
dlFailed = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue