[CR] Fix Non-DRM downloading
Thanks bytedream for your reverse engineering
This commit is contained in:
parent
e9c040ceb7
commit
5b8c497800
2 changed files with 40 additions and 18 deletions
18
crunchy.ts
18
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();
|
||||
|
|
|
|||
|
|
@ -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<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_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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue