added skipMuxOnSubFail flag

This commit is contained in:
stratumadev 2025-10-10 22:48:27 +02:00
parent 6847b36961
commit 90931e44f4
7 changed files with 38 additions and 27 deletions

View file

@ -6,7 +6,6 @@ import { CrunchyVideoPlayStreams, CrunchyAudioPlayStreams } from './enums';
export type CrunchyDownloadOptions = {
hslang: string;
// kstream: number,
cstream: keyof typeof CrunchyVideoPlayStreams;
vstream: keyof typeof CrunchyVideoPlayStreams;
astream: keyof typeof CrunchyAudioPlayStreams;
@ -23,6 +22,8 @@ export type CrunchyDownloadOptions = {
waittime: number;
fsRetryTime: number;
dlsubs: string[];
subdlfailed?: boolean;
skipMuxOnSubFail: boolean;
skipsubs: boolean;
nosubs?: boolean;
mp4: boolean;
@ -77,7 +78,7 @@ export type CrunchyMuxOptions = {
defaultAudio: LanguageItem;
ccTag: string;
syncTiming: boolean;
};
} & CrunchyDownloadOptions;
export type CrunchyEpMeta = {
data: {

5
adn.ts
View file

@ -329,6 +329,7 @@ export default class AnimationDigitalNetwork implements ServiceClass {
this.cfg.bin = await yamlCfg.loadBinCfg();
let hasAudioStreams = false;
if (options.novids || data.filter((a) => a.type === 'Video').length === 0) return console.info('Skip muxing since no vids are downloaded');
if (options.subdlfailed && options.skipMuxOnSubFail) return console.info('Skip muxing since some subtitles failed to download');
if (data.some((a) => a.type === 'Audio')) {
hasAudioStreams = true;
}
@ -820,12 +821,14 @@ export default class AnimationDigitalNetwork implements ServiceClass {
const subtitlesUrlReq = await this.req.getData(streams.links.subtitles.all);
if (!subtitlesUrlReq.ok || !subtitlesUrlReq.res) {
console.error('Subtitle location request failed!');
options.subdlfailed = true;
return undefined;
}
const subtitleUrl = (await subtitlesUrlReq.res.json()) as { location: string };
const encryptedSubtitlesReq = await this.req.getData(subtitleUrl.location);
if (!encryptedSubtitlesReq.ok || !encryptedSubtitlesReq.res) {
console.error('Subtitle request failed!');
options.subdlfailed = true;
return undefined;
}
const encryptedSubtitles = await encryptedSubtitlesReq.res.text();
@ -839,6 +842,7 @@ export default class AnimationDigitalNetwork implements ServiceClass {
const subtitles = JSON.parse(decryptedData) as ADNSubtitles;
if (Object.keys(subtitles).length === 0) {
console.warn('No subtitles found.');
options.subdlfailed = true;
}
for (const subName in subtitles) {
let subLang: langsData.LanguageItem;
@ -930,6 +934,7 @@ export default class AnimationDigitalNetwork implements ServiceClass {
}
} else {
console.warn("Couldn't find subtitles.");
options.subdlfailed = true;
}
} else {
console.info('Subtitles downloading skipped!');

View file

@ -2877,11 +2877,13 @@ export default class Crunchy implements ServiceClass {
});
} else {
console.warn(`Failed to download subtitle: ${sxData.file}`);
options.subdlfailed = true;
}
}
}
} else {
console.warn("Can't find urls for subtitles!");
options.subdlfailed = true;
}
} else {
console.info('Subtitles downloading skipped!');
@ -2900,6 +2902,7 @@ export default class Crunchy implements ServiceClass {
this.cfg.bin = await yamlCfg.loadBinCfg();
let hasAudioStreams = false;
if (options.novids || data.filter((a) => a.type === 'Video').length === 0) return console.info('Skip muxing since no vids are downloaded');
if (options.subdlfailed && options.skipMuxOnSubFail) return console.info('Skip muxing since some subtitles failed to download');
if (data.some((a) => a.type === 'Audio')) {
hasAudioStreams = true;
}

View file

@ -1103,12 +1103,14 @@ export default class Hidive implements ServiceClass {
});
} else {
console.warn(`Failed to download subtitle: ${sxData.file}`);
options.subdlfailed = true;
}
}
subIndex++;
}
} else {
console.warn("Can't find urls for subtitles!");
options.subdlfailed = true;
}
} else {
console.info('Subtitles downloading skipped!');
@ -1125,6 +1127,7 @@ export default class Hidive implements ServiceClass {
this.cfg.bin = await yamlCfg.loadBinCfg();
let hasAudioStreams = false;
if (options.novids || data.filter((a) => a.type === 'Video').length === 0) return console.info('Skip muxing since no vids are downloaded');
if (options.subdlfailed && options.skipMuxOnSubFail) return console.info('Skip muxing since some subtitles failed to download');
if (data.some((a) => a.type === 'Audio')) {
hasAudioStreams = true;
}

View file

@ -46,7 +46,6 @@ export let argvC: {
extid: string | undefined;
q: number;
x: number;
// kstream: number;
cstream: keyof typeof CrunchyVideoPlayStreams;
vstream: keyof typeof CrunchyVideoPlayStreams;
astream: keyof typeof CrunchyAudioPlayStreams;
@ -54,6 +53,7 @@ export let argvC: {
partsize: number;
hslang: string;
dlsubs: string[];
skipMuxOnSubFail: boolean;
novids: boolean | undefined;
noaudio: boolean | undefined;
nosubs: boolean | undefined;
@ -82,7 +82,6 @@ export let argvC: {
$0: string;
dlVideoOnce: boolean;
chapters: boolean;
// crapi: 'android' | 'web';
removeBumpers: boolean;
originalFontSize: boolean;
keepAllVideos: boolean;

View file

@ -372,6 +372,18 @@ const args: TAppArg<boolean | number | string | unknown[]>[] = [
},
usage: '${sub1} ${sub2}'
},
{
name: 'skipMuxOnSubFail',
group: 'dl',
describe: 'Skips muxing when a subtitle download fails.',
docDescribe: true,
service: ['all'],
type: 'boolean',
usage: '',
default: {
default: false
}
},
{
name: 'noASSConv',
group: 'dl',

View file

@ -597,9 +597,6 @@ packages:
'@types/node-forge@1.3.14':
resolution: {integrity: sha512-mhVF2BnD4BO+jtOp7z1CdzaK4mbuK0LLQYAvdOLqHTavxFNq4zA1EmYkpnFjP8HOUzedfQkRnp0E2ulSAYSzAw==}
'@types/node@22.18.9':
resolution: {integrity: sha512-5yBtK0k/q8PjkMXbTfeIEP/XVYnz1R9qZJ3yUicdEW7ppdDJfe+MqXEhpqDL3mtn4Wvs1u0KLEG0RXzCgNpsSg==}
'@types/node@24.7.1':
resolution: {integrity: sha512-CmyhGZanP88uuC5GpWU9q+fI61j2SkhO3UGMUdfYRE6Bcy0ccyzn1Rqj9YAB/ZY4kOXmNf0ocah5GtphmLMP6Q==}
@ -785,8 +782,8 @@ packages:
bare-abort-controller:
optional: true
bare-fs@4.4.9:
resolution: {integrity: sha512-sh8UV8OvXBZa3Yg5rhF1LNH3U4DfHniexdqyUXelC1thQUxO9TCF37yvd1/7Ir+cgeSg/6YrXyH67xvRr7yaOg==}
bare-fs@4.4.10:
resolution: {integrity: sha512-arqVF+xX/rJHwrONZaSPhlzleT2gXwVs9rsAe1p1mIVwWZI2A76/raio+KwwxfWMO8oV9Wo90EaUkS2QwVmy4w==}
engines: {bare: '>=1.16.0'}
peerDependencies:
bare-buffer: '*'
@ -2022,9 +2019,6 @@ packages:
unbzip2-stream@1.4.3:
resolution: {integrity: sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==}
undici-types@6.21.0:
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
undici-types@7.14.0:
resolution: {integrity: sha512-QQiYxHuyZ9gQUIrmPo3IA+hUl4KYk8uSA7cHrcKd/l3p1OTpZcM0Tbp9x7FAtXdAYhlasd60ncPpgu6ihG6TOA==}
@ -2452,11 +2446,11 @@ snapshots:
'@types/body-parser@1.19.6':
dependencies:
'@types/connect': 3.4.38
'@types/node': 22.18.9
'@types/node': 24.7.1
'@types/connect@3.4.38':
dependencies:
'@types/node': 22.18.9
'@types/node': 24.7.1
'@types/cors@2.8.19':
dependencies:
@ -2506,11 +2500,7 @@ snapshots:
'@types/node-forge@1.3.14':
dependencies:
'@types/node': 22.18.9
'@types/node@22.18.9':
dependencies:
undici-types: 6.21.0
'@types/node': 24.7.1
'@types/node@24.7.1':
dependencies:
@ -2523,21 +2513,21 @@ snapshots:
'@types/send@0.17.5':
dependencies:
'@types/mime': 1.3.5
'@types/node': 22.18.9
'@types/node': 24.7.1
'@types/send@1.2.0':
dependencies:
'@types/node': 22.18.9
'@types/node': 24.7.1
'@types/serve-static@1.15.9':
dependencies:
'@types/http-errors': 2.0.5
'@types/node': 22.18.9
'@types/node': 24.7.1
'@types/send': 0.17.5
'@types/ws@8.18.1':
dependencies:
'@types/node': 22.18.9
'@types/node': 24.7.1
'@types/yargs-parser@21.0.3': {}
@ -2758,7 +2748,7 @@ snapshots:
bare-events@2.8.0: {}
bare-fs@4.4.9:
bare-fs@4.4.10:
dependencies:
bare-events: 2.8.0
bare-path: 3.0.0
@ -4038,7 +4028,7 @@ snapshots:
pump: 3.0.3
tar-stream: 3.1.7
optionalDependencies:
bare-fs: 4.4.9
bare-fs: 4.4.10
bare-path: 3.0.0
transitivePeerDependencies:
- bare-abort-controller
@ -4153,8 +4143,6 @@ snapshots:
buffer: 5.7.1
through: 2.3.8
undici-types@6.21.0: {}
undici-types@7.14.0: {}
undici@7.16.0: {}