Added argument support + Fixed CR bug where Quality was wrongly shown

This commit is contained in:
Izuco 2021-11-07 00:46:14 +01:00
parent aa40658599
commit e1e57458e2
No known key found for this signature in database
GPG key ID: 318460063D70949F
6 changed files with 16 additions and 23 deletions

View file

@ -1,13 +1,9 @@
#!/usr/bin/env node
// build-in
import path from 'path';
import fs from 'fs-extra';
// package program
import packageJson from './package.json';
console.log(`\n=== Crunchyroll Beta Downloader NX ${packageJson.version} ===\n`);
// plugins
import shlp from 'sei-helper';
import m3u8 from 'm3u8-parsed';
@ -63,6 +59,7 @@ const req = new reqModule.Req(domain, argv);
// select
export default (async () => {
console.log(`\n=== Multi Downloader NX ${packageJson.version} ===\n`);
// load binaries
cfg.bin = await yamlCfg.loadBinCfg();
// select mode
@ -1017,7 +1014,7 @@ async function getMedia(mMeta: CrunchyEpMeta){
console.log(`[WARN] The requested quality of ${argv.q} is greater than the maximun ${plQuality.length}.\n[WARN] Therefor the maximum will be capped at ${plQuality.length}.`);
quality = plQuality.length;
}
const selPlUrl = quality === 0 ? plSelectedList[plQuality.pop()?.dim as string] :
const selPlUrl = quality === 0 ? plSelectedList[plQuality[plQuality.length - 1].dim as string] :
plSelectedList[plQuality.map(a => a.dim)[quality - 1]] ? plSelectedList[plQuality.map(a => a.dim)[quality - 1]] : '';
console.log(`[INFO] Servers available:\n\t${plServerList.join('\n\t')}`);
console.log(`[INFO] Available qualities:\n\t${plQuality.map((a, ind) => `[${ind+1}] ${a.str}`).join('\n\t')}`);
@ -1026,11 +1023,11 @@ async function getMedia(mMeta: CrunchyEpMeta){
appstore.fn.push({
name: 'height',
type: 'number',
replaceWith: quality === 0 ? plQuality.pop()?.RESOLUTION.height as number : plQuality[quality - 1].RESOLUTION.height
replaceWith: quality === 0 ? plQuality[plQuality.length - 1].RESOLUTION.height as number : plQuality[quality - 1].RESOLUTION.height
}, {
name: 'width',
type: 'number',
replaceWith: quality === 0 ? plQuality.pop()?.RESOLUTION.width as number : plQuality[quality - 1].RESOLUTION.width
replaceWith: quality === 0 ? plQuality[plQuality.length - 1].RESOLUTION.width as number : plQuality[quality - 1].RESOLUTION.width
});
appstore.lang = curStream.audio_lang;
console.log(`[INFO] Selected quality: ${Object.keys(plSelectedList).find(a => plSelectedList[a] === selPlUrl)} @ ${plSelectedServer}`);
@ -1058,14 +1055,13 @@ async function getMedia(mMeta: CrunchyEpMeta){
if (!fs.existsSync(path.join(isAbsolut ? '' : cfg.dir.content, ...arr.slice(0, ind), val)))
fs.mkdirSync(path.join(isAbsolut ? '' : cfg.dir.content, ...arr.slice(0, ind), val));
});
const streamdlParams = {
fn: `${tsFile}.ts`,
const dlStreamByPl = await new streamdl({
output: `${tsFile}.ts`,
timeout: argv.timeout,
m3u8json: chunkPlaylist,
// baseurl: chunkPlaylist.baseUrl,
pcount: argv.tsparts,
partsOffset: 0,
};
const dlStreamByPl = await new streamdl(streamdlParams).download();
threads: argv.partsize
}).download();
if(!dlStreamByPl.ok){
console.log(`[ERROR] DL Stats: ${JSON.stringify(dlStreamByPl.parts)}\n`);
dlFailed = true;

View file

@ -6,7 +6,6 @@ import path from 'path';
import packageJson from './package.json';
// program name
console.log(`\n=== Funimation Downloader NX ${packageJson.version} ===\n`);
const api_host = 'https://prod-api-funimationnow.dadcdigital.com/api';
// modules extra
@ -56,6 +55,7 @@ let title = '',
// main
export default (async () => {
// load binaries
console.log(`\n=== Multi Downloader NX ${packageJson.version} ===\n`);
cfg.bin = await yamlCfg.loadBinCfg();
if (argv.allDubs) {
argv.dub = appYargs.dubLang;
@ -375,7 +375,7 @@ async function getEpisode(fnSlug: {
return true;
}
});
if(streamIds.length <1){
if(streamIds.length < 1){
console.log('[ERROR] Track not selected\n');
return;
}

View file

@ -1,8 +1,6 @@
import { appArgv } from './modules/module.app-args';
import * as yamlCfg from './modules/module.cfg-loader';
import funimation from './funi';
import crunchy from './crunchy';
import update from './modules/module.updater';
(async () => {
@ -13,9 +11,9 @@ import update from './modules/module.updater';
await update(argv.update);
if (argv.service === 'funi') {
await funimation();
(await import('./funi')).default();
} else if (argv.service === 'crunchy') {
await crunchy();
(await import('./crunchy')).default();
}
})();

View file

@ -1,5 +1,3 @@
#!/usr/bin/env node
// build requirements
import fs from 'fs-extra';
import pkg from '../package.json';

View file

@ -99,7 +99,7 @@ export default (async (force = false) => {
return {
path: a.filename.slice(0, -2) + 'js',
content: transpileModule((await got(a.raw_url)).body, {
compilerOptions: tsConfig as unknown as CompilerOptions
compilerOptions: tsConfig.compilerOptions as unknown as CompilerOptions
}).outputText,
type: a.status === 'modified' ? ApplyType.UPDATE : a.status === 'added' ? ApplyType.ADD : ApplyType.DELETE
};

View file

@ -12,6 +12,7 @@
},
"exclude": [
"./videos",
"./tsc.ts"
"./tsc.ts",
"lib/**/*"
]
}