[CR] Fix Non-DRM downloading

Thanks bytedream for your reverse engineering
This commit is contained in:
AnimeDL 2024-04-19 15:42:44 -07:00
parent 282fc1ac1a
commit fb58d306bc
2 changed files with 40 additions and 18 deletions

View file

@ -232,7 +232,7 @@ export default class Crunchy implements ServiceClass {
}).toString(); }).toString();
const authReqOpts: reqModule.Params = { const authReqOpts: reqModule.Params = {
method: 'POST', method: 'POST',
headers: api.beta_authHeaderMob, headers: api.crunchyAuthHeaderSwitch,
body: authData body: authData
}; };
const authReq = await this.req.getData(api.beta_auth, authReqOpts); const authReq = await this.req.getData(api.beta_auth, authReqOpts);
@ -255,12 +255,12 @@ export default class Crunchy implements ServiceClass {
}).toString(); }).toString();
const authReqOpts: reqModule.Params = { const authReqOpts: reqModule.Params = {
method: 'POST', method: 'POST',
headers: api.beta_authHeaderMob, headers: api.crunchyAuthHeaderSwitch,
body: authData body: authData
}; };
const authReq = await this.req.getData(api.beta_auth, authReqOpts); const authReq = await this.req.getData(api.beta_auth, authReqOpts);
if(!authReq.ok || !authReq.res){ if(!authReq.ok || !authReq.res){
console.error('Authentication failed!'); console.error('Anonymous Authentication failed!');
return; return;
} }
this.token = await authReq.res.json(); this.token = await authReq.res.json();
@ -305,12 +305,15 @@ export default class Crunchy implements ServiceClass {
}).toString(); }).toString();
const authReqOpts: reqModule.Params = { const authReqOpts: reqModule.Params = {
method: 'POST', method: 'POST',
headers: api.beta_authHeaderMob, headers: api.crunchyAuthHeaderSwitch,
body: authData body: authData
}; };
const authReq = await this.req.getData(api.beta_auth, authReqOpts); const authReq = await this.req.getData(api.beta_auth, authReqOpts);
if(!authReq.ok || !authReq.res){ if(!authReq.ok || !authReq.res){
console.error('Token Authentication failed!'); 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; return;
} }
this.token = await authReq.res.json(); this.token = await authReq.res.json();
@ -339,12 +342,15 @@ export default class Crunchy implements ServiceClass {
}).toString(); }).toString();
const authReqOpts: reqModule.Params = { const authReqOpts: reqModule.Params = {
method: 'POST', method: 'POST',
headers: api.beta_authHeaderMob, headers: api.crunchyAuthHeaderSwitch,
body: authData body: authData
}; };
const authReq = await this.req.getData(api.beta_auth, authReqOpts); const authReq = await this.req.getData(api.beta_auth, authReqOpts);
if(!authReq.ok || !authReq.res){ 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; return;
} }
this.token = await authReq.res.json(); this.token = await authReq.res.json();

View file

@ -24,16 +24,27 @@ export type APIType = {
collections: string collections: string
// beta api // beta api
beta_auth: string beta_auth: string
beta_authBasic: string authBasic: string
beta_authBasicMob: string authBasicMob: string
authBasicSwitch: string,
beta_profile: string beta_profile: string
beta_cmsToken: string beta_cmsToken: string
search: string search: string
cms: string cms: string
beta_browse: string beta_browse: string
beta_cms: string, beta_cms: string,
beta_authHeader: Record<string, string>, /**
beta_authHeaderMob: Record<string, string>, * Web Header
*/
crunchyAuthHeader: Record<string, string>,
/**
* Mobile Header
*/
cruncyhAuthHeaderMob: Record<string, string>,
/**
* Switch Header
*/
crunchyAuthHeaderSwitch: Record<string, string>,
hd_apikey: string, hd_apikey: string,
hd_devName: string, hd_devName: string,
hd_appId: string, hd_appId: string,
@ -62,16 +73,18 @@ const api: APIType = {
collections: `${domain.api}/list_collections.0.json`, collections: `${domain.api}/list_collections.0.json`,
// beta api // beta api
beta_auth: `${domain.api_beta}/auth/v1/token`, beta_auth: `${domain.api_beta}/auth/v1/token`,
beta_authBasic: 'Basic bm9haWhkZXZtXzZpeWcwYThsMHE6', authBasic: 'Basic bm9haWhkZXZtXzZpeWcwYThsMHE6',
beta_authBasicMob: 'Basic bm12anNoZmtueW14eGtnN2ZiaDk6WllJVnJCV1VQYmNYRHRiRDIyVlNMYTZiNFdRb3Mzelg=', authBasicMob: 'Basic bm12anNoZmtueW14eGtnN2ZiaDk6WllJVnJCV1VQYmNYRHRiRDIyVlNMYTZiNFdRb3Mzelg=',
authBasicSwitch: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=',
beta_profile: `${domain.api_beta}/accounts/v1/me/profile`, beta_profile: `${domain.api_beta}/accounts/v1/me/profile`,
beta_cmsToken: `${domain.api_beta}/index/v2`, beta_cmsToken: `${domain.api_beta}/index/v2`,
search: `${domain.api_beta}/content/v2/discover/search`, search: `${domain.api_beta}/content/v2/discover/search`,
cms: `${domain.api_beta}/content/v2/cms`, cms: `${domain.api_beta}/content/v2/cms`,
beta_browse: `${domain.api_beta}/content/v1/browse`, beta_browse: `${domain.api_beta}/content/v1/browse`,
beta_cms: `${domain.api_beta}/cms/v2`, beta_cms: `${domain.api_beta}/cms/v2`,
beta_authHeader: {}, crunchyAuthHeader: {},
beta_authHeaderMob: {}, cruncyhAuthHeaderMob: {},
crunchyAuthHeaderSwitch: {},
//hidive API //hidive API
hd_apikey: '508efd7b42d546e19cc24f4d0b414e57e351ca73', hd_apikey: '508efd7b42d546e19cc24f4d0b414e57e351ca73',
hd_devName: 'Android', hd_devName: 'Android',
@ -86,11 +99,14 @@ const api: APIType = {
}; };
// set header // set header
api.beta_authHeader = { api.crunchyAuthHeader = {
Authorization: api.beta_authBasic, Authorization: api.authBasic,
}; };
api.beta_authHeaderMob = { api.cruncyhAuthHeaderMob = {
Authorization: api.beta_authBasicMob, Authorization: api.authBasicMob,
};
api.crunchyAuthHeaderSwitch = {
Authorization: api.authBasicSwitch,
}; };
export { export {