From 5b8c497800770143573c3bdbb164e6573e0c2a85 Mon Sep 17 00:00:00 2001 From: AnimeDL Date: Fri, 19 Apr 2024 15:42:44 -0700 Subject: [PATCH 1/3] [CR] Fix Non-DRM downloading Thanks bytedream for your reverse engineering --- crunchy.ts | 18 +++++++++++------ modules/module.api-urls.ts | 40 ++++++++++++++++++++++++++------------ 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/crunchy.ts b/crunchy.ts index 4f3e1e9..25718cb 100644 --- a/crunchy.ts +++ b/crunchy.ts @@ -232,7 +232,7 @@ export default class Crunchy implements ServiceClass { }).toString(); const authReqOpts: reqModule.Params = { method: 'POST', - headers: api.beta_authHeaderMob, + headers: api.crunchyAuthHeaderSwitch, body: authData }; const authReq = await this.req.getData(api.beta_auth, authReqOpts); @@ -255,12 +255,12 @@ export default class Crunchy implements ServiceClass { }).toString(); const authReqOpts: reqModule.Params = { method: 'POST', - headers: api.beta_authHeaderMob, + headers: api.crunchyAuthHeaderSwitch, body: authData }; const authReq = await this.req.getData(api.beta_auth, authReqOpts); if(!authReq.ok || !authReq.res){ - console.error('Authentication failed!'); + console.error('Anonymous Authentication failed!'); return; } this.token = await authReq.res.json(); @@ -305,12 +305,15 @@ export default class Crunchy implements ServiceClass { }).toString(); const authReqOpts: reqModule.Params = { method: 'POST', - headers: api.beta_authHeaderMob, + headers: api.crunchyAuthHeaderSwitch, body: authData }; const authReq = await this.req.getData(api.beta_auth, authReqOpts); if(!authReq.ok || !authReq.res){ console.error('Token Authentication failed!'); + if (authReq.res?.status == 400) { + console.warn('Token is likely wrong (Or invalid for given API), please login again!'); + } return; } this.token = await authReq.res.json(); @@ -339,12 +342,15 @@ export default class Crunchy implements ServiceClass { }).toString(); const authReqOpts: reqModule.Params = { method: 'POST', - headers: api.beta_authHeaderMob, + headers: api.crunchyAuthHeaderSwitch, body: authData }; const authReq = await this.req.getData(api.beta_auth, authReqOpts); if(!authReq.ok || !authReq.res){ - console.error('Authentication failed!'); + console.error('Token Refresh Failed!'); + if (authReq.res?.status == 400) { + console.warn('Token is likely wrong, please login again!'); + } return; } this.token = await authReq.res.json(); diff --git a/modules/module.api-urls.ts b/modules/module.api-urls.ts index 29d74da..c40c67c 100644 --- a/modules/module.api-urls.ts +++ b/modules/module.api-urls.ts @@ -24,16 +24,27 @@ export type APIType = { collections: string // beta api beta_auth: string - beta_authBasic: string - beta_authBasicMob: string + authBasic: string + authBasicMob: string + authBasicSwitch: string, beta_profile: string beta_cmsToken: string search: string cms: string beta_browse: string beta_cms: string, - beta_authHeader: Record, - beta_authHeaderMob: Record, + /** + * Web Header + */ + crunchyAuthHeader: Record, + /** + * Mobile Header + */ + cruncyhAuthHeaderMob: Record, + /** + * Switch Header + */ + crunchyAuthHeaderSwitch: Record, hd_apikey: string, hd_devName: string, hd_appId: string, @@ -62,16 +73,18 @@ const api: APIType = { collections: `${domain.api}/list_collections.0.json`, // beta api beta_auth: `${domain.api_beta}/auth/v1/token`, - beta_authBasic: 'Basic bm9haWhkZXZtXzZpeWcwYThsMHE6', - beta_authBasicMob: 'Basic bm12anNoZmtueW14eGtnN2ZiaDk6WllJVnJCV1VQYmNYRHRiRDIyVlNMYTZiNFdRb3Mzelg=', + authBasic: 'Basic bm9haWhkZXZtXzZpeWcwYThsMHE6', + authBasicMob: 'Basic bm12anNoZmtueW14eGtnN2ZiaDk6WllJVnJCV1VQYmNYRHRiRDIyVlNMYTZiNFdRb3Mzelg=', + authBasicSwitch: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=', beta_profile: `${domain.api_beta}/accounts/v1/me/profile`, beta_cmsToken: `${domain.api_beta}/index/v2`, search: `${domain.api_beta}/content/v2/discover/search`, cms: `${domain.api_beta}/content/v2/cms`, beta_browse: `${domain.api_beta}/content/v1/browse`, beta_cms: `${domain.api_beta}/cms/v2`, - beta_authHeader: {}, - beta_authHeaderMob: {}, + crunchyAuthHeader: {}, + cruncyhAuthHeaderMob: {}, + crunchyAuthHeaderSwitch: {}, //hidive API hd_apikey: '508efd7b42d546e19cc24f4d0b414e57e351ca73', hd_devName: 'Android', @@ -86,11 +99,14 @@ const api: APIType = { }; // set header -api.beta_authHeader = { - Authorization: api.beta_authBasic, +api.crunchyAuthHeader = { + Authorization: api.authBasic, }; -api.beta_authHeaderMob = { - Authorization: api.beta_authBasicMob, +api.cruncyhAuthHeaderMob = { + Authorization: api.authBasicMob, +}; +api.crunchyAuthHeaderSwitch = { + Authorization: api.authBasicSwitch, }; export { From e47deb7c57bc9d812c48ef0e659eb39a6b2579ee Mon Sep 17 00:00:00 2001 From: AnimeDL Date: Fri, 19 Apr 2024 15:45:21 -0700 Subject: [PATCH 2/3] Increment version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c6ea795..c5ce097 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "multi-downloader-nx", "short_name": "aniDL", - "version": "4.7.1", + "version": "4.7.2", "description": "Downloader for Crunchyroll, Funimation, or Hidive via CLI or GUI", "keywords": [ "download", From b2a602e96e2d54e820876c416131ea4c6c2be48b Mon Sep 17 00:00:00 2001 From: AnimeDL Date: Fri, 19 Apr 2024 22:45:30 +0000 Subject: [PATCH 3/3] Increment version + Documentation --- docs/DOCUMENTATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/DOCUMENTATION.md b/docs/DOCUMENTATION.md index 7b9b398..80cd209 100644 --- a/docs/DOCUMENTATION.md +++ b/docs/DOCUMENTATION.md @@ -1,4 +1,4 @@ -# multi-downloader-nx (4.7.1v) +# multi-downloader-nx (4.7.2v) 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).