Compare commits

..

16 commits

Author SHA1 Message Date
AnimeDL
64c927c761 Fix Docker Release + Documentation 2024-08-15 19:28:29 +00:00
AnimeDL
16e7fcb71e Fix Docker Release 2024-08-15 12:27:56 -07:00
AnimeDL
d61d7e471f
Update docker.yml
Change docker account
2024-08-15 11:40:39 -07:00
AnimeDL
64272b7689 [ADN] Fix DE only streams 2024-08-15 10:12:21 -07:00
AnimeDL
35777ecb58 [ADN] Forgot to fix login 2024-07-28 09:15:29 -07:00
AnimeDL
423ad7b2c9 [ADN] Fix refresh token request 2024-07-28 00:03:52 -07:00
AnimeDL
5cbead06bc Minor grammar fix 2024-07-18 09:44:12 -07:00
AnimeDL
1704bfb4ec [CR} Hotfix downloading
Pretty hacked together, but should work just fine. I'll work on a proper removal of the old API here soon + Documentation
2024-07-08 23:56:45 +00:00
AnimeDL
b488834c0f [CR} Hotfix downloading
Pretty hacked together, but should work just fine. I'll work on a proper removal of the old API here soon
2024-07-08 16:56:13 -07:00
AnimeDL
8d59666a6c [CR] Fix issue with too many streams when novids and noaudio
Fixes issue where you would have too many active streams if using no videos and no audio downloading
2024-06-29 07:49:13 -07:00
AnimeDL
c14a963024 [CR] Add device_id caching
Fixes issue with creating a lot of random device IDs by saving the created device id in the config + Documentation
2024-06-28 23:52:33 +00:00
AnimeDL
0026de73bf [CR] Add device_id caching
Fixes issue with creating a lot of random device IDs by saving the created device id in the config
2024-06-28 16:52:05 -07:00
AnimeDL
d3238d22ba [CR] Whoops
Forgot the other 3 login places + Documentation
2024-06-28 16:32:14 +00:00
AnimeDL
ab090a6858 [CR] Whoops
Forgot the other 3 login places
2024-06-28 09:31:42 -07:00
AnimeDL
64783a0529 [CR] Hotfix login
Also increment version + Documentation
2024-06-28 16:21:11 +00:00
AnimeDL
05d679e6ca [CR] Hotfix login
Also increment version
2024-06-28 09:20:35 -07:00
10 changed files with 59 additions and 92 deletions

View file

@ -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 }}

View file

@ -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 }}

View file

@ -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 };

View file

@ -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
View file

@ -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){

View file

@ -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,

View file

@ -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).

View file

@ -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 = {

View file

@ -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

View file

@ -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",