mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-03-11 17:45:30 +00:00
[CR] Improve version detection
Improves the version selection and detection to work for more than just --srz. This should help prevent API errors on non --srz requests
This commit is contained in:
parent
7cab2cbab3
commit
5417db41fd
2 changed files with 19 additions and 3 deletions
1
@types/crunchyTypes.d.ts
vendored
1
@types/crunchyTypes.d.ts
vendored
|
|
@ -35,6 +35,7 @@ export type CrunchyDownloadOptions = {
|
|||
chapters: boolean,
|
||||
fontName: string | undefined,
|
||||
fontSize: number,
|
||||
dubLang: string[],
|
||||
}
|
||||
|
||||
export type CrunchyMultiDownload = {
|
||||
|
|
|
|||
21
crunchy.ts
21
crunchy.ts
|
|
@ -148,6 +148,10 @@ export default class Crunchy implements ServiceClass {
|
|||
}
|
||||
else if(argv.e){
|
||||
await this.refreshToken();
|
||||
if (argv.dubLang.length > 1) {
|
||||
console.info('One show can only be downloaded with one dub. Use --srz instead.');
|
||||
}
|
||||
argv.dubLang = [argv.dubLang[0]];
|
||||
const selected = await this.getObjectById(argv.e, false);
|
||||
for (const select of selected as Partial<CrunchyEpMeta>[]) {
|
||||
if (!(await this.downloadEpisode(select as CrunchyEpMeta, {...argv, skipsubs: false}))) {
|
||||
|
|
@ -158,6 +162,10 @@ export default class Crunchy implements ServiceClass {
|
|||
return true;
|
||||
} else if (argv.extid) {
|
||||
await this.refreshToken();
|
||||
if (argv.dubLang.length > 1) {
|
||||
console.info('One show can only be downloaded with one dub. Use --srz instead.');
|
||||
}
|
||||
argv.dubLang = [argv.dubLang[0]];
|
||||
const selected = await this.getObjectById(argv.extid, false, true);
|
||||
for (const select of selected as Partial<CrunchyEpMeta>[]) {
|
||||
if (!(await this.downloadEpisode(select as CrunchyEpMeta, {...argv, skipsubs: false}))) {
|
||||
|
|
@ -1165,10 +1173,17 @@ export default class Crunchy implements ServiceClass {
|
|||
|
||||
//Get Media GUID
|
||||
let mediaId = mMeta.mediaId;
|
||||
if (mMeta.versions && mMeta.lang) {
|
||||
currentVersion = mMeta.versions.find(a => a.audio_locale == mMeta.lang?.cr_locale);
|
||||
if (mMeta.versions) {
|
||||
if (mMeta.lang) {
|
||||
currentVersion = mMeta.versions.find(a => a.audio_locale == mMeta.lang?.cr_locale);
|
||||
} else if (options.dubLang.length == 1) {
|
||||
const currentLang = langsData.languages.find(a => a.code == options.dubLang[0]);
|
||||
currentVersion = mMeta.versions.find(a => a.audio_locale == currentLang?.cr_locale);
|
||||
} else if (mMeta.versions.length == 1) {
|
||||
currentVersion = mMeta.versions[0];
|
||||
}
|
||||
if (!currentVersion?.media_guid) {
|
||||
console.error('Selected language not found.');
|
||||
console.error('Selected language not found in versions.');
|
||||
continue;
|
||||
}
|
||||
isPrimary = currentVersion.original;
|
||||
|
|
|
|||
Loading…
Reference in a new issue