[CR} Hotfix downloading
Pretty hacked together, but should work just fine. I'll work on a proper removal of the old API here soon
This commit is contained in:
parent
8d59666a6c
commit
b488834c0f
4 changed files with 19 additions and 74 deletions
4
@types/crunchyPlayStreams.d.ts
vendored
4
@types/crunchyPlayStreams.d.ts
vendored
|
|
@ -1,6 +1,8 @@
|
||||||
|
import { Locale } from './playbackData';
|
||||||
|
|
||||||
export interface CrunchyPlayStream {
|
export interface CrunchyPlayStream {
|
||||||
assetId: string;
|
assetId: string;
|
||||||
audioLocale: string;
|
audioLocale: Locale;
|
||||||
bifs: string;
|
bifs: string;
|
||||||
burnedInLocale: string;
|
burnedInLocale: string;
|
||||||
captions: { [key: string]: Caption };
|
captions: { [key: string]: Caption };
|
||||||
|
|
|
||||||
4
@types/playbackData.d.ts
vendored
4
@types/playbackData.d.ts
vendored
|
|
@ -59,11 +59,11 @@ export interface Meta {
|
||||||
versions: Version[];
|
versions: Version[];
|
||||||
audio_locale: Locale;
|
audio_locale: Locale;
|
||||||
closed_captions: Subtitles;
|
closed_captions: Subtitles;
|
||||||
captions: Record<unknown>;
|
captions: Subtitles;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Subtitles {
|
export interface Subtitles {
|
||||||
'': SubtitleInfo;
|
''?: SubtitleInfo;
|
||||||
'en-US'?: SubtitleInfo;
|
'en-US'?: SubtitleInfo;
|
||||||
'es-LA'?: SubtitleInfo;
|
'es-LA'?: SubtitleInfo;
|
||||||
'es-419'?: SubtitleInfo;
|
'es-419'?: SubtitleInfo;
|
||||||
|
|
|
||||||
83
crunchy.ts
83
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 { CrunchyDownloadOptions, CrunchyEpMeta, CrunchyMuxOptions, CrunchyMultiDownload, DownloadedMedia, ParseItem, SeriesSearch, SeriesSearchItem } from './@types/crunchyTypes';
|
||||||
import { ObjectInfo } from './@types/objectInfo';
|
import { ObjectInfo } from './@types/objectInfo';
|
||||||
import parseFileName, { Variable } from './modules/module.filename';
|
import parseFileName, { Variable } from './modules/module.filename';
|
||||||
import { CrunchyStreams, PlaybackData } from './@types/playbackData';
|
import { CrunchyStreams, PlaybackData, Subtitles } from './@types/playbackData';
|
||||||
import { downloaded } from './modules/module.downloadArchive';
|
import { downloaded } from './modules/module.downloadArchive';
|
||||||
import parseSelect from './modules/module.parseSelect';
|
import parseSelect from './modules/module.parseSelect';
|
||||||
import { AvailableFilenameVars, getDefault } from './modules/module.args';
|
import { AvailableFilenameVars, getDefault } from './modules/module.args';
|
||||||
|
|
@ -1371,73 +1371,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let pbData = { total: 0, data: [{}], meta: {} } as PlaybackData;
|
const pbData = { total: 0, data: [{}], meta: {} } as PlaybackData;
|
||||||
if (this.api == 'android') {
|
|
||||||
const videoStreamsReq = [
|
|
||||||
api.beta_cms,
|
|
||||||
`${this.cmsToken.cms.bucket}/videos/${mediaId}/streams`,
|
|
||||||
'?',
|
|
||||||
new URLSearchParams({
|
|
||||||
'force_locale': '',
|
|
||||||
'preferred_audio_language': 'ja-JP',
|
|
||||||
'locale': this.locale,
|
|
||||||
'Policy': this.cmsToken.cms.policy,
|
|
||||||
'Signature': this.cmsToken.cms.signature,
|
|
||||||
'Key-Pair-Id': this.cmsToken.cms.key_pair_id,
|
|
||||||
}),
|
|
||||||
].join('');
|
|
||||||
|
|
||||||
let playbackReq = await this.req.getData(videoStreamsReq as string, AuthHeaders);
|
|
||||||
if(!playbackReq.ok || !playbackReq.res){
|
|
||||||
console.error('Request Stream URLs FAILED! Attempting fallback');
|
|
||||||
|
|
||||||
const videoStreamsReq = [
|
|
||||||
domain.api_beta,
|
|
||||||
mMeta.playback,
|
|
||||||
'?',
|
|
||||||
new URLSearchParams({
|
|
||||||
'force_locale': '',
|
|
||||||
'preferred_audio_language': 'ja-JP',
|
|
||||||
'locale': this.locale,
|
|
||||||
'Policy': this.cmsToken.cms.policy,
|
|
||||||
'Signature': this.cmsToken.cms.signature,
|
|
||||||
'Key-Pair-Id': this.cmsToken.cms.key_pair_id,
|
|
||||||
}),
|
|
||||||
].join('');
|
|
||||||
playbackReq = await this.req.getData(videoStreamsReq as string, AuthHeaders);
|
|
||||||
if(!playbackReq.ok || !playbackReq.res){
|
|
||||||
console.error('Fallback Request Stream URLs FAILED!');
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const pbDataAndroid = await playbackReq.res.json() as CrunchyAndroidStreams;
|
|
||||||
pbData = {
|
|
||||||
total: 0,
|
|
||||||
data: [{}/*pbDataAndroid.streams*/],
|
|
||||||
meta: {
|
|
||||||
audio_locale: pbDataAndroid.audio_locale,
|
|
||||||
bifs: pbDataAndroid.bifs,
|
|
||||||
captions: pbDataAndroid.captions,
|
|
||||||
closed_captions: pbDataAndroid.closed_captions,
|
|
||||||
media_id: pbDataAndroid.media_id,
|
|
||||||
subtitles: pbDataAndroid.subtitles,
|
|
||||||
versions: pbDataAndroid.versions
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
let playbackReq = await this.req.getData(`${api.cms}/videos/${mediaId}/streams`, AuthHeaders);
|
|
||||||
if(!playbackReq.ok || !playbackReq.res){
|
|
||||||
console.error('Request Stream URLs FAILED! Attempting fallback');
|
|
||||||
playbackReq = await this.req.getData(`${domain.api_beta}${mMeta.playback}`, AuthHeaders);
|
|
||||||
if(!playbackReq.ok || !playbackReq.res){
|
|
||||||
console.error('Fallback Request Stream URLs FAILED!');
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pbData = await playbackReq.res.json() as PlaybackData;
|
|
||||||
pbData.data = [{}];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let playStream: CrunchyPlayStream | null = null;
|
let playStream: CrunchyPlayStream | null = null;
|
||||||
if (options.cstream !== 'none') {
|
if (options.cstream !== 'none') {
|
||||||
|
|
@ -1458,6 +1392,15 @@ export default class Crunchy implements ServiceClass {
|
||||||
url: playStream.url,
|
url: playStream.url,
|
||||||
hardsub_locale: ''
|
hardsub_locale: ''
|
||||||
};
|
};
|
||||||
|
pbData.meta = {
|
||||||
|
audio_locale: playStream.audioLocale,
|
||||||
|
bifs: [playStream.bifs],
|
||||||
|
captions: playStream.captions,
|
||||||
|
closed_captions: playStream.captions,
|
||||||
|
media_id: playStream.assetId,
|
||||||
|
subtitles: playStream.subtitles,
|
||||||
|
versions: playStream.versions
|
||||||
|
};
|
||||||
pbData.data[0][`adaptive_${options.cstream}_${playStream.url.includes('m3u8') ? 'hls' : 'dash'}_drm`] = {
|
pbData.data[0][`adaptive_${options.cstream}_${playStream.url.includes('m3u8') ? 'hls' : 'dash'}_drm`] = {
|
||||||
...derivedPlaystreams
|
...derivedPlaystreams
|
||||||
};
|
};
|
||||||
|
|
@ -2098,7 +2041,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
const subsData = Object.values(pbData.meta.subtitles);
|
const subsData = Object.values(pbData.meta.subtitles);
|
||||||
const capsData = Object.values(pbData.meta.closed_captions);
|
const capsData = Object.values(pbData.meta.closed_captions);
|
||||||
const subsDataMapped = subsData.map((s) => {
|
const subsDataMapped = subsData.map((s) => {
|
||||||
const subLang = langsData.fixAndFindCrLC(s.locale);
|
const subLang = langsData.fixAndFindCrLC(s.language);
|
||||||
return {
|
return {
|
||||||
...s,
|
...s,
|
||||||
isCC: false,
|
isCC: false,
|
||||||
|
|
@ -2107,7 +2050,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
};
|
};
|
||||||
}).concat(
|
}).concat(
|
||||||
capsData.map((s) => {
|
capsData.map((s) => {
|
||||||
const subLang = langsData.fixAndFindCrLC(s.locale);
|
const subLang = langsData.fixAndFindCrLC(s.language);
|
||||||
return {
|
return {
|
||||||
...s,
|
...s,
|
||||||
isCC: true,
|
isCC: true,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "multi-downloader-nx",
|
"name": "multi-downloader-nx",
|
||||||
"short_name": "aniDL",
|
"short_name": "aniDL",
|
||||||
"version": "5.1.3",
|
"version": "5.1.4",
|
||||||
"description": "Downloader for Crunchyroll, Hidive, AnimeOnegai, and AnimationDigitalNetwork with CLI and GUI",
|
"description": "Downloader for Crunchyroll, Hidive, AnimeOnegai, and AnimationDigitalNetwork with CLI and GUI",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"download",
|
"download",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue