Compare commits
16 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64c927c761 | ||
|
|
16e7fcb71e | ||
|
|
d61d7e471f | ||
|
|
64272b7689 | ||
|
|
35777ecb58 | ||
|
|
423ad7b2c9 | ||
|
|
5cbead06bc | ||
|
|
1704bfb4ec | ||
|
|
b488834c0f | ||
|
|
8d59666a6c | ||
|
|
c14a963024 | ||
|
|
0026de73bf | ||
|
|
d3238d22ba | ||
|
|
ab090a6858 | ||
|
|
64783a0529 | ||
|
|
05d679e6ca |
10 changed files with 59 additions and 92 deletions
4
.github/workflows/docker.yml
vendored
4
.github/workflows/docker.yml
vendored
|
|
@ -27,6 +27,6 @@ jobs:
|
|||
github-token: ${{ github.token }}
|
||||
push: ${{ github.ref == 'refs/heads/master' }}
|
||||
tags: |
|
||||
"izuco/multi-downloader-nx:latest"
|
||||
"multidl/multi-downloader-nx:latest"
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
|
|
|
|||
2
.github/workflows/release-matrix.yml
vendored
2
.github/workflows/release-matrix.yml
vendored
|
|
@ -61,6 +61,6 @@ jobs:
|
|||
github-token: ${{ github.token }}
|
||||
push: true
|
||||
tags: |
|
||||
"izuco/multi-downloader-nx:${{ github.event.release.tag_name }}"
|
||||
"multidl/multi-downloader-nx:${{ github.event.release.tag_name }}"
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
|
|
|
|||
4
@types/crunchyPlayStreams.d.ts
vendored
4
@types/crunchyPlayStreams.d.ts
vendored
|
|
@ -1,6 +1,8 @@
|
|||
import { Locale } from './playbackData';
|
||||
|
||||
export interface CrunchyPlayStream {
|
||||
assetId: string;
|
||||
audioLocale: string;
|
||||
audioLocale: Locale;
|
||||
bifs: string;
|
||||
burnedInLocale: string;
|
||||
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[];
|
||||
audio_locale: Locale;
|
||||
closed_captions: Subtitles;
|
||||
captions: Record<unknown>;
|
||||
captions: Subtitles;
|
||||
}
|
||||
|
||||
export interface Subtitles {
|
||||
'': SubtitleInfo;
|
||||
''?: SubtitleInfo;
|
||||
'en-US'?: SubtitleInfo;
|
||||
'es-LA'?: SubtitleInfo;
|
||||
'es-419'?: SubtitleInfo;
|
||||
|
|
|
|||
14
adn.ts
14
adn.ts
|
|
@ -204,8 +204,6 @@ export default class AnimationDigitalNetwork implements ServiceClass {
|
|||
return { isOk: false, reason: new Error('Authentication failed') };
|
||||
}
|
||||
this.token = await authReq.res.json();
|
||||
const cookies = this.parseCookies(authReq.res.headers.get('Set-Cookie'));
|
||||
this.token.refreshToken = cookies.adnrt;
|
||||
yamlCfg.saveADNToken(this.token);
|
||||
console.info('Authentication Success');
|
||||
return { isOk: true, value: undefined };
|
||||
|
|
@ -216,19 +214,16 @@ export default class AnimationDigitalNetwork implements ServiceClass {
|
|||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.token.accessToken}`,
|
||||
'Cookie': `adnrt=${this.token.refreshToken}`,
|
||||
'X-Access-Token': this.token.accessToken
|
||||
'X-Access-Token': this.token.accessToken,
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
body: '{}'
|
||||
body: JSON.stringify({refreshToken: this.token.refreshToken})
|
||||
});
|
||||
if(!authReq.ok || !authReq.res){
|
||||
console.error('Token refresh failed!');
|
||||
return { isOk: false, reason: new Error('Token refresh failed') };
|
||||
}
|
||||
this.token = await authReq.res.json();
|
||||
const cookies = this.parseCookies(authReq.res.headers.get('Set-Cookie'));
|
||||
//this.token.refreshtoken = this.token.refreshToken;
|
||||
this.token.refreshToken = cookies.adnrt;
|
||||
yamlCfg.saveADNToken(this.token);
|
||||
return { isOk: true, value: undefined };
|
||||
}
|
||||
|
|
@ -463,7 +458,8 @@ export default class AnimationDigitalNetwork implements ServiceClass {
|
|||
|
||||
const configReq = await this.req.getData(`https://gw.api.animationdigitalnetwork.fr/player/video/${data.id}/configuration`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.token.accessToken}`
|
||||
Authorization: `Bearer ${this.token.accessToken}`,
|
||||
'X-Target-Distribution': this.locale
|
||||
}
|
||||
});
|
||||
if(!configReq.ok || !configReq.res){
|
||||
|
|
|
|||
114
crunchy.ts
114
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 { CrunchyStreams, PlaybackData } from './@types/playbackData';
|
||||
import { CrunchyStreams, PlaybackData, Subtitles } from './@types/playbackData';
|
||||
import { downloaded } from './modules/module.downloadArchive';
|
||||
import parseSelect from './modules/module.parseSelect';
|
||||
import { AvailableFilenameVars, getDefault } from './modules/module.args';
|
||||
|
|
@ -45,6 +45,7 @@ import { CrunchyChapters, CrunchyChapter, CrunchyOldChapter } from './@types/cru
|
|||
import vtt2ass from './modules/module.vtt2ass';
|
||||
import { CrunchyPlayStream } from './@types/crunchyPlayStreams';
|
||||
import { CrunchyPlayStreams } from './@types/enums';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
|
||||
export type sxItem = {
|
||||
language: langsData.LanguageItem,
|
||||
|
|
@ -225,11 +226,14 @@ export default class Crunchy implements ServiceClass {
|
|||
}
|
||||
|
||||
public async doAuth(data: AuthData): Promise<AuthResponse> {
|
||||
const uuid = randomUUID();
|
||||
const authData = new URLSearchParams({
|
||||
'username': data.username,
|
||||
'password': data.password,
|
||||
'grant_type': 'password',
|
||||
'scope': 'offline_access'
|
||||
'scope': 'offline_access',
|
||||
'device_id': uuid,
|
||||
'device_type': 'Chrome on Windows'
|
||||
}).toString();
|
||||
const authReqOpts: reqModule.Params = {
|
||||
method: 'POST',
|
||||
|
|
@ -242,6 +246,7 @@ export default class Crunchy implements ServiceClass {
|
|||
return { isOk: false, reason: new Error('Authentication failed') };
|
||||
}
|
||||
this.token = await authReq.res.json();
|
||||
this.token.device_id = uuid;
|
||||
this.token.expires = new Date(Date.now() + this.token.expires_in);
|
||||
yamlCfg.saveCRToken(this.token);
|
||||
await this.getProfile();
|
||||
|
|
@ -250,9 +255,12 @@ export default class Crunchy implements ServiceClass {
|
|||
}
|
||||
|
||||
public async doAnonymousAuth(){
|
||||
const uuid = randomUUID();
|
||||
const authData = new URLSearchParams({
|
||||
'grant_type': 'client_id',
|
||||
'scope': 'offline_access',
|
||||
'device_id': uuid,
|
||||
'device_type': 'Chrome on Windows'
|
||||
}).toString();
|
||||
const authReqOpts: reqModule.Params = {
|
||||
method: 'POST',
|
||||
|
|
@ -265,6 +273,7 @@ export default class Crunchy implements ServiceClass {
|
|||
return;
|
||||
}
|
||||
this.token = await authReq.res.json();
|
||||
this.token.device_id = uuid;
|
||||
this.token.expires = new Date(Date.now() + this.token.expires_in);
|
||||
yamlCfg.saveCRToken(this.token);
|
||||
}
|
||||
|
|
@ -299,11 +308,14 @@ export default class Crunchy implements ServiceClass {
|
|||
}
|
||||
|
||||
public async loginWithToken(refreshToken: string) {
|
||||
const uuid = randomUUID();
|
||||
const authData = new URLSearchParams({
|
||||
'refresh_token': this.token.refresh_token,
|
||||
'grant_type': 'refresh_token',
|
||||
//'grant_type': 'etp_rt_cookie',
|
||||
'scope': 'offline_access'
|
||||
'scope': 'offline_access',
|
||||
'device_id': uuid,
|
||||
'device_type': 'Chrome on Windows'
|
||||
}).toString();
|
||||
const authReqOpts: reqModule.Params = {
|
||||
method: 'POST',
|
||||
|
|
@ -319,6 +331,7 @@ export default class Crunchy implements ServiceClass {
|
|||
return;
|
||||
}
|
||||
this.token = await authReq.res.json();
|
||||
this.token.device_id = uuid;
|
||||
this.token.expires = new Date(Date.now() + this.token.expires_in);
|
||||
yamlCfg.saveCRToken(this.token);
|
||||
await this.getProfile(false);
|
||||
|
|
@ -337,11 +350,14 @@ export default class Crunchy implements ServiceClass {
|
|||
} else {
|
||||
//console.info('[WARN] The token has expired compleatly. I will try to refresh the token anyway, but you might have to reauth.');
|
||||
}
|
||||
const uuid = this.token.device_id || randomUUID();
|
||||
const authData = new URLSearchParams({
|
||||
'refresh_token': this.token.refresh_token,
|
||||
'grant_type': 'refresh_token',
|
||||
//'grant_type': 'etp_rt_cookie',
|
||||
'scope': 'offline_access'
|
||||
'scope': 'offline_access',
|
||||
'device_id': uuid,
|
||||
'device_type': 'Chrome on Windows'
|
||||
}).toString();
|
||||
const authReqOpts: reqModule.Params = {
|
||||
method: 'POST',
|
||||
|
|
@ -357,6 +373,7 @@ export default class Crunchy implements ServiceClass {
|
|||
return;
|
||||
}
|
||||
this.token = await authReq.res.json();
|
||||
this.token.device_id = uuid;
|
||||
this.token.expires = new Date(Date.now() + this.token.expires_in);
|
||||
yamlCfg.saveCRToken(this.token);
|
||||
}
|
||||
|
|
@ -1354,73 +1371,7 @@ export default class Crunchy implements ServiceClass {
|
|||
}
|
||||
}
|
||||
|
||||
let 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 = [{}];
|
||||
}
|
||||
|
||||
const pbData = { total: 0, data: [{}], meta: {} } as PlaybackData;
|
||||
|
||||
let playStream: CrunchyPlayStream | null = null;
|
||||
if (options.cstream !== 'none') {
|
||||
|
|
@ -1441,6 +1392,15 @@ export default class Crunchy implements ServiceClass {
|
|||
url: playStream.url,
|
||||
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`] = {
|
||||
...derivedPlaystreams
|
||||
};
|
||||
|
|
@ -1567,6 +1527,14 @@ export default class Crunchy implements ServiceClass {
|
|||
|
||||
let tsFile = undefined;
|
||||
|
||||
// Delete the stream if it's not needed
|
||||
if (options.novids && options.noaudio) {
|
||||
if (playStream) {
|
||||
await this.refreshToken(true, true);
|
||||
await this.req.getData(`https://cr-play-service.prd.crunchyrollsvc.com/v1/token/${currentVersion ? currentVersion.guid : currentMediaId}/${playStream.token}`, {...{method: 'DELETE'}, ...AuthHeaders});
|
||||
}
|
||||
}
|
||||
|
||||
if(!dlFailed && curStream !== undefined && !(options.novids && options.noaudio)){
|
||||
const streamPlaylistsReq = await this.req.getData(curStream.url, AuthHeaders);
|
||||
if(!streamPlaylistsReq.ok || !streamPlaylistsReq.res){
|
||||
|
|
@ -2073,7 +2041,7 @@ export default class Crunchy implements ServiceClass {
|
|||
const subsData = Object.values(pbData.meta.subtitles);
|
||||
const capsData = Object.values(pbData.meta.closed_captions);
|
||||
const subsDataMapped = subsData.map((s) => {
|
||||
const subLang = langsData.fixAndFindCrLC(s.locale);
|
||||
const subLang = langsData.fixAndFindCrLC(s.language);
|
||||
return {
|
||||
...s,
|
||||
isCC: false,
|
||||
|
|
@ -2082,7 +2050,7 @@ export default class Crunchy implements ServiceClass {
|
|||
};
|
||||
}).concat(
|
||||
capsData.map((s) => {
|
||||
const subLang = langsData.fixAndFindCrLC(s.locale);
|
||||
const subLang = langsData.fixAndFindCrLC(s.language);
|
||||
return {
|
||||
...s,
|
||||
isCC: true,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# multi-downloader-nx (5.1.0v)
|
||||
# multi-downloader-nx (5.1.5v)
|
||||
|
||||
If you find any bugs in this documentation or in the program itself please report it [over on GitHub](https://github.com/anidl/multi-downloader-nx/issues).
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ const api: APIType = {
|
|||
// beta api
|
||||
beta_auth: `${domain.api_beta}/auth/v1/token`,
|
||||
authBasic: 'Basic bm9haWhkZXZtXzZpeWcwYThsMHE6',
|
||||
authBasicMob: 'Basic d2piMV90YThta3Y3X2t4aHF6djc6MnlSWlg0Y0psX28yMzRqa2FNaXRTbXNLUVlGaUpQXzU=',
|
||||
authBasicMob: 'Basic dXU4aG0wb2g4dHFpOWV0eXl2aGo6SDA2VnVjRnZUaDJ1dEYxM0FBS3lLNE85UTRhX3BlX1o=',
|
||||
authBasicSwitch: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=',
|
||||
beta_profile: `${domain.api_beta}/accounts/v1/me/profile`,
|
||||
beta_cmsToken: `${domain.api_beta}/index/v2`,
|
||||
|
|
@ -107,6 +107,7 @@ api.crunchyAuthHeader = {
|
|||
|
||||
api.crunchyAuthHeaderMob = {
|
||||
Authorization: api.authBasicMob,
|
||||
'user-agent': 'Crunchyroll/3.60.0 Android/9 okhttp/4.12.0'
|
||||
};
|
||||
|
||||
api.crunchyAuthHeaderSwitch = {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ export class Req {
|
|||
}
|
||||
// debug
|
||||
if(this.debug){
|
||||
console.debug('[DEBUG] GOT OPTIONS:');
|
||||
console.debug('[DEBUG] FETCH OPTIONS:');
|
||||
console.debug(options);
|
||||
}
|
||||
// try do request
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "multi-downloader-nx",
|
||||
"short_name": "aniDL",
|
||||
"version": "5.1.0",
|
||||
"version": "5.1.5",
|
||||
"description": "Downloader for Crunchyroll, Hidive, AnimeOnegai, and AnimationDigitalNetwork with CLI and GUI",
|
||||
"keywords": [
|
||||
"download",
|
||||
|
|
|
|||
Loading…
Reference in a new issue