mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-03-11 17:45:30 +00:00
forgot a couple of new urls
This commit is contained in:
parent
160c8a1cb4
commit
8e267c8e0a
1 changed files with 42 additions and 42 deletions
84
crunchy.ts
84
crunchy.ts
|
|
@ -70,7 +70,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
public checkToken(): boolean {
|
public checkToken(): boolean {
|
||||||
return Object.keys(this.cmsToken.cms_web ?? {}).length > 0;
|
return Object.keys(this.cmsToken.cms ?? {}).length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async cli() {
|
public async cli() {
|
||||||
|
|
@ -185,7 +185,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
|
|
||||||
public async logShowRawById(id: string) {
|
public async logShowRawById(id: string) {
|
||||||
// check token
|
// check token
|
||||||
if (!this.cmsToken.cms_web) {
|
if (!this.cmsToken.cms) {
|
||||||
console.error('Authentication required!');
|
console.error('Authentication required!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -215,7 +215,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
|
|
||||||
public async logSeasonRawById(id: string) {
|
public async logSeasonRawById(id: string) {
|
||||||
// check token
|
// check token
|
||||||
if (!this.cmsToken.cms_web) {
|
if (!this.cmsToken.cms) {
|
||||||
console.error('Authentication required!');
|
console.error('Authentication required!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -231,16 +231,16 @@ export default class Crunchy implements ServiceClass {
|
||||||
//get episode info
|
//get episode info
|
||||||
const reqEpsListOpts = [
|
const reqEpsListOpts = [
|
||||||
api.cms_bucket,
|
api.cms_bucket,
|
||||||
this.cmsToken.cms_web.bucket,
|
this.cmsToken.cms.bucket,
|
||||||
'/episodes?',
|
'/episodes?',
|
||||||
new URLSearchParams({
|
new URLSearchParams({
|
||||||
force_locale: '',
|
force_locale: '',
|
||||||
preferred_audio_language: 'ja-JP',
|
preferred_audio_language: 'ja-JP',
|
||||||
locale: this.locale,
|
locale: this.locale,
|
||||||
season_id: id,
|
season_id: id,
|
||||||
Policy: this.cmsToken.cms_web.policy,
|
Policy: this.cmsToken.cms.policy,
|
||||||
Signature: this.cmsToken.cms_web.signature,
|
Signature: this.cmsToken.cms.signature,
|
||||||
'Key-Pair-Id': this.cmsToken.cms_web.key_pair_id
|
'Key-Pair-Id': this.cmsToken.cms.key_pair_id
|
||||||
})
|
})
|
||||||
].join('');
|
].join('');
|
||||||
const reqEpsList = await this.req.getData(reqEpsListOpts, AuthHeaders);
|
const reqEpsList = await this.req.getData(reqEpsListOpts, AuthHeaders);
|
||||||
|
|
@ -266,7 +266,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
|
|
||||||
public async logShowListRaw() {
|
public async logShowListRaw() {
|
||||||
// check token
|
// check token
|
||||||
if (!this.cmsToken.cms_web) {
|
if (!this.cmsToken.cms) {
|
||||||
console.error('Authentication required!');
|
console.error('Authentication required!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -632,8 +632,8 @@ export default class Crunchy implements ServiceClass {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ifNeeded && this.cmsToken.cms_web) {
|
if (ifNeeded && this.cmsToken.cms) {
|
||||||
if (!(Date.now() >= new Date(this.cmsToken.cms_web.expires).getTime())) {
|
if (!(Date.now() >= new Date(this.cmsToken.cms.expires).getTime())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -650,27 +650,27 @@ export default class Crunchy implements ServiceClass {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.cmsToken = await cmsTokenReq.res.json();
|
this.cmsToken = await cmsTokenReq.res.json();
|
||||||
console.info('Your Country: %s\n', this.cmsToken.cms_web?.bucket.split('/')[1]);
|
console.info('Your Country: %s\n', this.cmsToken.cms?.bucket.split('/')[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getCmsData() {
|
public async getCmsData() {
|
||||||
// check token
|
// check token
|
||||||
if (!this.cmsToken.cms_web) {
|
if (!this.cmsToken.cms) {
|
||||||
console.error('Authentication required!');
|
console.error('Authentication required!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// opts
|
// opts
|
||||||
const indexReqOpts = [
|
const indexReqOpts = [
|
||||||
api.cms_bucket,
|
api.cms_bucket,
|
||||||
this.cmsToken.cms_web.bucket,
|
this.cmsToken.cms.bucket,
|
||||||
'/index?',
|
'/index?',
|
||||||
new URLSearchParams({
|
new URLSearchParams({
|
||||||
force_locale: '',
|
force_locale: '',
|
||||||
preferred_audio_language: 'ja-JP',
|
preferred_audio_language: 'ja-JP',
|
||||||
locale: this.locale,
|
locale: this.locale,
|
||||||
Policy: this.cmsToken.cms_web.policy,
|
Policy: this.cmsToken.cms.policy,
|
||||||
Signature: this.cmsToken.cms_web.signature,
|
Signature: this.cmsToken.cms.signature,
|
||||||
'Key-Pair-Id': this.cmsToken.cms_web.key_pair_id
|
'Key-Pair-Id': this.cmsToken.cms.key_pair_id
|
||||||
})
|
})
|
||||||
].join('');
|
].join('');
|
||||||
const indexReq = await this.req.getData(indexReqOpts, {
|
const indexReq = await this.req.getData(indexReqOpts, {
|
||||||
|
|
@ -947,7 +947,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
pad = pad || 0;
|
pad = pad || 0;
|
||||||
hideSeriesTitle = hideSeriesTitle !== undefined ? hideSeriesTitle : false;
|
hideSeriesTitle = hideSeriesTitle !== undefined ? hideSeriesTitle : false;
|
||||||
// check token
|
// check token
|
||||||
if (!this.cmsToken.cms_web) {
|
if (!this.cmsToken.cms) {
|
||||||
console.error('Authentication required!');
|
console.error('Authentication required!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -990,7 +990,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
|
|
||||||
public async logMovieListingById(id: string, pad?: number) {
|
public async logMovieListingById(id: string, pad?: number) {
|
||||||
pad = pad || 2;
|
pad = pad || 2;
|
||||||
if (!this.cmsToken.cms_web) {
|
if (!this.cmsToken.cms) {
|
||||||
console.error('Authentication required!');
|
console.error('Authentication required!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1078,14 +1078,14 @@ export default class Crunchy implements ServiceClass {
|
||||||
await this.logObject(i, 2);
|
await this.logObject(i, 2);
|
||||||
}
|
}
|
||||||
// calculate pages
|
// calculate pages
|
||||||
const itemPad = parseInt(new URL(newlyAddedResults.__href__, domain.cr_www).searchParams.get('start') as string);
|
const itemPad = parseInt(new URL(newlyAddedResults.__href__, domain.cr_api).searchParams.get('start') as string);
|
||||||
const pageCur = itemPad > 0 ? Math.ceil(itemPad / 25) + 1 : 1;
|
const pageCur = itemPad > 0 ? Math.ceil(itemPad / 25) + 1 : 1;
|
||||||
const pageMax = Math.ceil(newlyAddedResults.total / 25);
|
const pageMax = Math.ceil(newlyAddedResults.total / 25);
|
||||||
console.info(` Total results: ${newlyAddedResults.total} (Page: ${pageCur}/${pageMax})`);
|
console.info(` Total results: ${newlyAddedResults.total} (Page: ${pageCur}/${pageMax})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getSeasonById(id: string, numbers: number, e: string | undefined, but: boolean, all: boolean): Promise<ResponseBase<CrunchyEpMeta[]>> {
|
public async getSeasonById(id: string, numbers: number, e: string | undefined, but: boolean, all: boolean): Promise<ResponseBase<CrunchyEpMeta[]>> {
|
||||||
if (!this.cmsToken.cms_web) {
|
if (!this.cmsToken.cms) {
|
||||||
console.error('Authentication required!');
|
console.error('Authentication required!');
|
||||||
return { isOk: false, reason: new Error('Authentication required') };
|
return { isOk: false, reason: new Error('Authentication required') };
|
||||||
}
|
}
|
||||||
|
|
@ -1110,16 +1110,16 @@ export default class Crunchy implements ServiceClass {
|
||||||
//get episode info CMS
|
//get episode info CMS
|
||||||
const reqEpsCMSListOpts = [
|
const reqEpsCMSListOpts = [
|
||||||
api.cms_bucket,
|
api.cms_bucket,
|
||||||
this.cmsToken.cms_web.bucket,
|
this.cmsToken.cms.bucket,
|
||||||
'/episodes?',
|
'/episodes?',
|
||||||
new URLSearchParams({
|
new URLSearchParams({
|
||||||
force_locale: '',
|
force_locale: '',
|
||||||
preferred_audio_language: 'ja-JP',
|
preferred_audio_language: 'ja-JP',
|
||||||
locale: this.locale,
|
locale: this.locale,
|
||||||
season_id: id,
|
season_id: id,
|
||||||
Policy: this.cmsToken.cms_web.policy,
|
Policy: this.cmsToken.cms.policy,
|
||||||
Signature: this.cmsToken.cms_web.signature,
|
Signature: this.cmsToken.cms.signature,
|
||||||
'Key-Pair-Id': this.cmsToken.cms_web.key_pair_id
|
'Key-Pair-Id': this.cmsToken.cms.key_pair_id
|
||||||
})
|
})
|
||||||
].join('');
|
].join('');
|
||||||
const reqEpsCMSList = await this.req.getData(reqEpsCMSListOpts, AuthHeaders);
|
const reqEpsCMSList = await this.req.getData(reqEpsCMSListOpts, AuthHeaders);
|
||||||
|
|
@ -1132,7 +1132,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
|
|
||||||
//get episode info API
|
//get episode info API
|
||||||
const reqEpsListOpts = [
|
const reqEpsListOpts = [
|
||||||
domain.cr_www,
|
domain.cr_api,
|
||||||
'/content/v2/cms/seasons/',
|
'/content/v2/cms/seasons/',
|
||||||
id,
|
id,
|
||||||
'/episodes?',
|
'/episodes?',
|
||||||
|
|
@ -1295,7 +1295,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getObjectById(e?: string, earlyReturn?: boolean, external_id?: boolean): Promise<ObjectInfo | Partial<CrunchyEpMeta>[] | undefined> {
|
public async getObjectById(e?: string, earlyReturn?: boolean, external_id?: boolean): Promise<ObjectInfo | Partial<CrunchyEpMeta>[] | undefined> {
|
||||||
if (!this.cmsToken.cms_web) {
|
if (!this.cmsToken.cms) {
|
||||||
console.error('Authentication required!');
|
console.error('Authentication required!');
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
@ -1307,7 +1307,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
for (const ob of epFilter.values) {
|
for (const ob of epFilter.values) {
|
||||||
const extIdReqOpts = [
|
const extIdReqOpts = [
|
||||||
api.cms_bucket,
|
api.cms_bucket,
|
||||||
this.cmsToken.cms_web.bucket,
|
this.cmsToken.cms.bucket,
|
||||||
'/channels/crunchyroll/objects',
|
'/channels/crunchyroll/objects',
|
||||||
'?',
|
'?',
|
||||||
new URLSearchParams({
|
new URLSearchParams({
|
||||||
|
|
@ -1315,9 +1315,9 @@ export default class Crunchy implements ServiceClass {
|
||||||
preferred_audio_language: 'ja-JP',
|
preferred_audio_language: 'ja-JP',
|
||||||
locale: this.locale,
|
locale: this.locale,
|
||||||
external_id: ob,
|
external_id: ob,
|
||||||
Policy: this.cmsToken.cms_web.policy,
|
Policy: this.cmsToken.cms.policy,
|
||||||
Signature: this.cmsToken.cms_web.signature,
|
Signature: this.cmsToken.cms.signature,
|
||||||
'Key-Pair-Id': this.cmsToken.cms_web.key_pair_id
|
'Key-Pair-Id': this.cmsToken.cms.key_pair_id
|
||||||
})
|
})
|
||||||
].join('');
|
].join('');
|
||||||
|
|
||||||
|
|
@ -1397,7 +1397,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
if (doEpsFilter.values.length > 0) {
|
if (doEpsFilter.values.length > 0) {
|
||||||
const objectReqOpts = [
|
const objectReqOpts = [
|
||||||
api.cms_bucket,
|
api.cms_bucket,
|
||||||
this.cmsToken.cms_web.bucket,
|
this.cmsToken.cms.bucket,
|
||||||
'/objects/',
|
'/objects/',
|
||||||
doEpsFilter.values.join(','),
|
doEpsFilter.values.join(','),
|
||||||
'?',
|
'?',
|
||||||
|
|
@ -1405,9 +1405,9 @@ export default class Crunchy implements ServiceClass {
|
||||||
force_locale: '',
|
force_locale: '',
|
||||||
preferred_audio_language: 'ja-JP',
|
preferred_audio_language: 'ja-JP',
|
||||||
locale: this.locale,
|
locale: this.locale,
|
||||||
Policy: this.cmsToken.cms_web.policy,
|
Policy: this.cmsToken.cms.policy,
|
||||||
Signature: this.cmsToken.cms_web.signature,
|
Signature: this.cmsToken.cms.signature,
|
||||||
'Key-Pair-Id': this.cmsToken.cms_web.key_pair_id
|
'Key-Pair-Id': this.cmsToken.cms.key_pair_id
|
||||||
})
|
})
|
||||||
].join('');
|
].join('');
|
||||||
const objectReq = await this.req.getData(objectReqOpts, AuthHeaders);
|
const objectReq = await this.req.getData(objectReqOpts, AuthHeaders);
|
||||||
|
|
@ -1562,7 +1562,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
}
|
}
|
||||||
| undefined
|
| undefined
|
||||||
> {
|
> {
|
||||||
if (!this.cmsToken.cms_web) {
|
if (!this.cmsToken.cms) {
|
||||||
console.error('Authentication required!');
|
console.error('Authentication required!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -3387,7 +3387,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async parseSeriesById(id: string) {
|
public async parseSeriesById(id: string) {
|
||||||
if (!this.cmsToken.cms_web) {
|
if (!this.cmsToken.cms) {
|
||||||
console.error('Authentication required!');
|
console.error('Authentication required!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -3418,7 +3418,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getSeasonDataById(item: SeriesSearchItem, log = false) {
|
public async getSeasonDataById(item: SeriesSearchItem, log = false) {
|
||||||
if (!this.cmsToken.cms_web) {
|
if (!this.cmsToken.cms) {
|
||||||
console.error('Authentication required!');
|
console.error('Authentication required!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -3448,16 +3448,16 @@ export default class Crunchy implements ServiceClass {
|
||||||
//get episode info CMS
|
//get episode info CMS
|
||||||
const reqEpsCMSListOpts = [
|
const reqEpsCMSListOpts = [
|
||||||
api.cms_bucket,
|
api.cms_bucket,
|
||||||
this.cmsToken.cms_web.bucket,
|
this.cmsToken.cms.bucket,
|
||||||
'/episodes?',
|
'/episodes?',
|
||||||
new URLSearchParams({
|
new URLSearchParams({
|
||||||
force_locale: '',
|
force_locale: '',
|
||||||
preferred_audio_language: 'ja-JP',
|
preferred_audio_language: 'ja-JP',
|
||||||
locale: this.locale,
|
locale: this.locale,
|
||||||
season_id: id,
|
season_id: id,
|
||||||
Policy: this.cmsToken.cms_web.policy,
|
Policy: this.cmsToken.cms.policy,
|
||||||
Signature: this.cmsToken.cms_web.signature,
|
Signature: this.cmsToken.cms.signature,
|
||||||
'Key-Pair-Id': this.cmsToken.cms_web.key_pair_id
|
'Key-Pair-Id': this.cmsToken.cms.key_pair_id
|
||||||
})
|
})
|
||||||
].join('');
|
].join('');
|
||||||
const reqEpsCMSList = await this.req.getData(reqEpsCMSListOpts, AuthHeaders);
|
const reqEpsCMSList = await this.req.getData(reqEpsCMSListOpts, AuthHeaders);
|
||||||
|
|
@ -3470,7 +3470,7 @@ export default class Crunchy implements ServiceClass {
|
||||||
|
|
||||||
//get episode info API
|
//get episode info API
|
||||||
const reqEpsListOpts = [
|
const reqEpsListOpts = [
|
||||||
domain.cr_www,
|
domain.cr_api,
|
||||||
'/content/v2/cms/seasons/',
|
'/content/v2/cms/seasons/',
|
||||||
id,
|
id,
|
||||||
'/episodes?',
|
'/episodes?',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue