diff --git a/crunchy.ts b/crunchy.ts index 42fd117..deef69b 100644 --- a/crunchy.ts +++ b/crunchy.ts @@ -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; diff --git a/funi.ts b/funi.ts index aec4a44..080a4cc 100644 --- a/funi.ts +++ b/funi.ts @@ -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; } diff --git a/index.ts b/index.ts index eff9c9d..0ad8e72 100644 --- a/index.ts +++ b/index.ts @@ -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(); } })(); \ No newline at end of file diff --git a/modules/build.ts b/modules/build.ts index baa5f5b..a4cdfe7 100644 --- a/modules/build.ts +++ b/modules/build.ts @@ -1,5 +1,3 @@ -#!/usr/bin/env node - // build requirements import fs from 'fs-extra'; import pkg from '../package.json'; diff --git a/modules/module.updater.ts b/modules/module.updater.ts index b822d3b..5fabd6c 100644 --- a/modules/module.updater.ts +++ b/modules/module.updater.ts @@ -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 }; diff --git a/tsconfig.json b/tsconfig.json index 88bbdbd..a398dfd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,7 @@ }, "exclude": [ "./videos", - "./tsc.ts" + "./tsc.ts", + "lib/**/*" ] }